Skip to content

hendry19901990/ecies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This implementation is direct fork of Kylom's implementation. I claim no authorship over this code apart from some minor modifications. Just works in Linux and Mac

ecies implements the Elliptic Curve Integrated Encryption Scheme.

The package is designed to be compliant with the appropriate NIST standards, and therefore doesn't support the full SEC 1 algorithm set.

STATUS:

ecies should be ready for use. The ASN.1 support is only complete so far as to supported the listed algorithms before.

CAVEATS

  1. CMAC support is currently not present.

SUPPORTED ALGORITHMS

    SYMMETRIC CIPHERS               HASH FUNCTIONS
         AES128                         SHA-1
         AES192                        SHA-224
         AES256                        SHA-256
                                       SHA-384
    ELLIPTIC CURVE                     SHA-512
         P256
         P384       KEY DERIVATION FUNCTION
         P521        NIST SP 800-65a Concatenation KDF

Curve P224 isn't supported because it does not provide a minimum security level of AES128 with HMAC-SHA1. According to NIST SP 800-57, the security level of P224 is 112 bits of security. Symmetric ciphers use CTR-mode; message tags are computed using HMAC- function.

CURVE SELECTION

According to NIST SP 800-57, the following curves should be selected:

+----------------+-------+
| SYMMETRIC SIZE | CURVE |
+----------------+-------+
|     128-bit    |  P256 |
+----------------+-------+
|     192-bit    |  P384 |
+----------------+-------+
|     256-bit    |  P521 |
+----------------+-------+

TODO

  1. Look at serialising the parameters with the SEC 1 ASN.1 module.
  2. Validate ASN.1 formats with SEC 1.

TEST VECTORS

The only test vectors I've found so far date from 1993, predating AES and including only 163-bit curves. Therefore, there are no published test vectors to compare to.

Install library

go get -u  github.com/hendry19901990/ecies

Sample

package main

import (
  "fmt"
  "crypto/rand"
  "github.com/hendry19901990/ecies"
)

func main() {
  //Load Private Key from Random
  prv1, _ := ecies.GenerateKey(rand.Reader, ecies.DefaultCurve, nil)
  //Load Private Key from string of sha256
  prv2, _ := ecies.HexKey("4067d588f8866d1820c3bb1315c9ce5091b656935c8efc3220dcb51bb48460e0")

  message := []byte("Hello, world.") // plain text
  ct, err := prv1.EncryptShared(rand.Reader, &prv2.PublicKey, message, nil, nil)
  if err != nil {
    fmt.Println(err.Error())
    return
  }

  fmt.Printf("Message encrypt:  %v\n", ct) // ciphered text

  pt, err := prv2.Decrypt(ct, nil, nil)
  if err != nil {
    fmt.Println(err.Error())
    return
  }

  fmt.Printf("Message decrypt:  %s\n", string(pt)) // plain text

}

LICENSE

ecies is released under the same license as the Go source code. See the LICENSE file for details.

REFERENCES

About

Lightweight library for ECC encryption/decryption shared secret

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors