|
OpenSSL ECC Engine
1.0
OpenSSL Engine implementation using ATECC508 for ECC key storage and ECDSA, ECDH, and RNG.
|
Implementation of OpenSSL ENGINE callback functions for ECC See reference code in ec_pmeth.c. More...
#include <stdint.h>#include <assert.h>#include <stdarg.h>#include <openssl/engine.h>#include <openssl/ec.h>#include <crypto/ec/ec_lcl.h>#include <crypto/evp/evp.h>#include <crypto/evp/evp_locl.h>#include <crypto/asn1/asn1_locl.h>#include <crypto/ossl_typ.h>#include "ecc_meth.h"#include "platform.h"Macros | |
| #define | KEY_FORMAT_VERSION (1) |
Functions | |
| ATCA_STATUS | eccx08_get_enc_key (uint8_t *enckey, int16_t keysize) |
| A user defined function that fills a raw buffer (32 bytes) with the platform-specific encryption key. More... | |
| int | eccx08_eckey_fill_key (char *ptr, int size, uint8_t slot_id, uint8_t *serial_number, int serial_len) |
| Fills a raw buffer (32 bytes) with data to save into the private key structure. More... | |
| int | eccx08_eckey_encode_in_privkey (EC_KEY *eckey, uint8_t slot_id, uint8_t *serial_number, int serial_len) |
| Converts 32 bytes from ATECC508 format to the openssl EC_KEY structure. It allocates EC_KET structure and does not free it (must be a caller to free) More... | |
| int | eccx08_eckey_compare_privkey (EC_KEY *eckey, uint8_t slot_id, uint8_t *serial_number, int serial_len) |
| Checks if the private key in the openssl EC_KEY structure corresponds to the private key in the ATECCCX08 slot. More... | |
| int | eccx08_generate_key (EC_KEY *eckey, uint8_t *serial_number, int serial_len) |
| Generates a 32-byte private key then replaces it with token data using the eccx08_eckey_encode_in_privkey() call. More... | |
| int | eccx08_eckey_convert (EC_KEY **p_eckey, uint8_t *raw_pubkey, uint8_t *serial_number, int serial_len) |
| Converts raw 64 bytes of public key (ATECC508 format) to the openssl EC_KEY structure. It allocates EC_KEY structure and does not free it (must be a caller to free) More... | |
| int | eccx08_BN_encrypt (BIGNUM *number, uint8_t *iv, uint8_t *aes_key) |
| Encrypt a BIGNUM data using AES-256 OFB mode. More... | |
| int | eccx08_BN_decrypt (BIGNUM *number, uint8_t *iv, uint8_t *aes_key) |
| Decrypt a BIGNUM data using AES-256 OFB mode. Assuming that data there was encrypted using the eccx08_BN_encrypt(). More... | |
| int | eccx08_debug (const char *fmt,...) |
Variables | |
| uint8_t | test_priv_key [MEM_BLOCK_SIZE] |
| uint8_t | test_pub_key [MEM_BLOCK_SIZE *2] |
Implementation of OpenSSL ENGINE callback functions for ECC See reference code in ec_pmeth.c.
Copyright (c) 2015 Atmel Corporation. All rights reserved.
| int eccx08_BN_decrypt | ( | BIGNUM * | number, |
| uint8_t * | iv, | ||
| uint8_t * | aes_key | ||
| ) |
Decrypt a BIGNUM data using AES-256 OFB mode. Assuming that data there was encrypted using the eccx08_BN_encrypt().
| int eccx08_BN_encrypt | ( | BIGNUM * | number, |
| uint8_t * | iv, | ||
| uint8_t * | aes_key | ||
| ) |
Encrypt a BIGNUM data using AES-256 OFB mode.
| int eccx08_eckey_compare_privkey | ( | EC_KEY * | eckey, |
| uint8_t | slot_id, | ||
| uint8_t * | serial_number, | ||
| int | serial_len | ||
| ) |
Checks if the private key in the openssl EC_KEY structure corresponds to the private key in the ATECCCX08 slot.
eccx08_eckey_compare_privkey()
| [in,out] | eckey | Pointer to EC_KEY with Private key token on success |
| [in] | slot_id | ATECCX08 slot ID |
| [in] | serial_number | 9 bytes of ATECCX08 serial number |
| [in] | serial_len | Size of the ATECCX08 serial number buffer |
| int eccx08_eckey_convert | ( | EC_KEY ** | p_eckey, |
| uint8_t * | raw_pubkey, | ||
| uint8_t * | serial_number, | ||
| int | serial_len | ||
| ) |
Converts raw 64 bytes of public key (ATECC508 format) to the openssl EC_KEY structure. It allocates EC_KEY structure and does not free it (must be a caller to free)
| [out] | p_eckey | Pointer to EC_KEY with Public Key on success |
| [in] | raw_pubkey | Raw public key, 64 bytes length 32-byte X following with 32-byte Y |
| [in] | serial_number | 9 bytes of ATECCX08 serial number |
| [in] | serial_len | Size of the ATECCX08 serial number buffer |
| int eccx08_eckey_encode_in_privkey | ( | EC_KEY * | eckey, |
| uint8_t | slot_id, | ||
| uint8_t * | serial_number, | ||
| int | serial_len | ||
| ) |
Converts 32 bytes from ATECC508 format to the openssl EC_KEY structure. It allocates EC_KET structure and does not free it (must be a caller to free)
eccx08_eckey_encode_in_privkey()
| int eccx08_eckey_fill_key | ( | char * | ptr, |
| int | size, | ||
| uint8_t | slot_id, | ||
| uint8_t * | serial_number, | ||
| int | serial_len | ||
| ) |
Fills a raw buffer (32 bytes) with data to save into the private key structure.
| [in,out] | ptr | Pointer to a buffer to fill the key data |
| [in] | slot_id | ATECCX08 slot ID |
| [in] | serial_number | 9 bytes of ATECCX08 serial number |
| [in] | serial_len | Size of the ATECCX08 serial number buffer |
| int eccx08_generate_key | ( | EC_KEY * | eckey, |
| uint8_t * | serial_number, | ||
| int | serial_len | ||
| ) |
Generates a 32-byte private key then replaces it with token data using the eccx08_eckey_encode_in_privkey() call.
| [out] | p_eckey | Pointer to EC_KEY with Public Key on success |
| [in] | serial_number | 9 bytes of ATECCX08 serial number |
| [in] | serial_len | Size of the ATECCX08 serial number buffer |
| ATCA_STATUS eccx08_get_enc_key | ( | uint8_t * | enckey, |
| int16_t | keysize | ||
| ) |
A user defined function that fills a raw buffer (32 bytes) with the platform-specific encryption key.
USER: Platform needs to to provide secure storage for this encryption key
| [in,out] | enckey | Pointer to a buffer to fill with the encryption key data |
| [in] | keysize | The size of the enckey buffer (number of bytes should be MEM_BLOCK_SIZE) |
| uint8_t test_priv_key[MEM_BLOCK_SIZE] |
| uint8_t test_pub_key[MEM_BLOCK_SIZE *2] |
1.8.10