Coder Social home page Coder Social logo

easy-ecc's Introduction

easy-ecc

Please do not use this library, it is a very old fork of https://github.com/kmackay/micro-ecc, please use micro-ecc instead

A simple and secure ECDH and ECDSA library.

Features

  • Supports Windows and Linux/*nix (needs /dev/urandom).
  • Resistant to known side-channel attacks.
  • Twice as fast as OpenSSL for ECDSA verify and ECDH.
  • Written in C.
  • No dynamic memory allocation.
  • Support for 4 standard curves: secp128r1, secp192r1, secp256r1, and secp384r1
  • BSD 2-clause license.

Usage

I recommend just copying (or symlink) ecc.h and ecc.c into your project. Then just #include "ecc.h" to use the easy-ecc functions.

Function documentation

ecc_make_key

int ecc_make_key(
	uint8_t p_publicKey[ECC_BYTES+1],
	uint8_t p_privateKey[ECC_BYTES]
);

Create a public/private key pair.

Outputs:

  • p_publicKey - Will be filled in with the public key.
  • p_privateKey - Will be filled in with the private key.

Returns 1 if the key pair was generated successfully, 0 if an error occurred.

ecdh_shared_secret

int ecdh_shared_secret(
	const uint8_t p_publicKey[ECC_BYTES+1],
	const uint8_t p_privateKey[ECC_BYTES],
	uint8_t p_secret[ECC_BYTES]
);

Compute a shared secret given your secret key and someone else's public key. Note: It is recommended that you hash the result of ecdh_shared_secret before using it for symmetric encryption or HMAC.

Inputs:

  • p_publicKey - The public key of the remote party.
  • p_privateKey - Your private key.

Outputs:

  • p_secret - Will be filled in with the shared secret value.

Returns 1 if the shared secret was generated successfully, 0 if an error occurred.

ecdsa_sign

int ecdsa_sign(
	const uint8_t p_privateKey[ECC_BYTES],
	const uint8_t p_hash[ECC_BYTES],
	uint8_t p_signature[ECC_BYTES*2]
);

Generate an ECDSA signature for a given hash value.

Usage: Compute a hash of the data you wish to sign (SHA-2 is recommended) and pass it in to this function along with your private key.

Inputs:

  • p_privateKey - Your private key.
  • p_hash - The message hash to sign.

Outputs:

  • p_signature - Will be filled in with the signature value.

Returns 1 if the signature generated successfully, 0 if an error occurred.

ecdsa_verify

int ecdsa_verify(
	const uint8_t p_publicKey[ECC_BYTES+1],
	const uint8_t p_hash[ECC_BYTES],
	const uint8_t p_signature[ECC_BYTES*2]
);

Verify an ECDSA signature.

Usage: Compute the hash of the signed data using the same hash as the signer and pass it to this function along with the signer's public key and the signature values (r and s).

Inputs: p_publicKey - The signer's public key p_hash - The hash of the signed data. p_signature - The signature value.

Returns 1 if the signature is valid, 0 if it is invalid.

easy-ecc's People

Contributors

jestan avatar kmackay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.