39 #ifndef __ECC_METH_H__
40 #define __ECC_METH_H__
42 #include <openssl/engine.h>
43 #include <openssl/ossl_typ.h>
44 #include "atca_status.h"
45 #include "atcatls_cfg.h"
49 #define ECCX08_ENGINE_VERSION "01.00.00"
51 #define NID_id_ATECCX08 (1001)
53 #define TOKEN_FILE_VERSION (0x0)
54 #define PRIVATE_KEY_ID (0x1)
55 #define PUBLIC_KEY_ID (0x2)
56 #define KEY_LIMITS_LOCKED (0x1)
57 #define KEY_LIMITS_UNLOCKED (0x2)
58 #define KEY_LIMITS_COUNTED (0x3)
60 #define ECCX08_CMD_GET_VERSION (ENGINE_CMD_BASE)
61 #define ECCX08_CMD_GET_SIGNER_CERT (ENGINE_CMD_BASE + 1)
62 #define ECCX08_CMD_GET_PUB_KEY (ENGINE_CMD_BASE + 2)
63 #define ECCX08_CMD_GET_DEVICE_CERT (ENGINE_CMD_BASE + 3)
64 #define ECCX08_CMD_VERIFY_SIGNER_CERT (ENGINE_CMD_BASE + 4)
65 #define ECCX08_CMD_VERIFY_DEVICE_CERT (ENGINE_CMD_BASE + 5)
66 #define ECCX08_CMD_GET_ROOT_CERT (ENGINE_CMD_BASE + 6)
67 #define ECCX08_CMD_EXTRACT_ALL_CERTS (ENGINE_CMD_BASE + 7)
68 #define ECCX08_CMD_GET_PRIV_KEY (ENGINE_CMD_BASE + 8)
70 #define ECCX08_SLOT8_ENC_STORE_LEN (416)
73 #define MAX_RAND_BYTES (10037)
80 extern ATCAIfaceCfg *pCfg;
82 int eccx08_debug(
const char *fmt, ...);
90 const int **nids,
int nid);
92 const int **nids,
int nid);
102 int eccx08_ctrl(ENGINE *e,
int cmd,
long i,
void *p,
void (*f)());
110 int eccx08_cmd_ctrl(ENGINE *e,
int cmd,
long i,
void *p,
void (*f)(
void));
113 extern uint8_t test_priv_key[MEM_BLOCK_SIZE];
114 extern uint8_t test_pub_key[MEM_BLOCK_SIZE*2];
116 uint8_t *serial_number,
int serial_len);
118 uint8_t *serial_number,
int serial_len);
120 uint8_t *serial_number,
int serial_len);
123 uint8_t *serial_number,
int serial_len);
132 #endif //__ECC_METH_H__
ECDSA_METHOD eccx08_ecdsa
eccx08_ecdsa is an OpenSSL ECDSA_METHOD structure specific to the ateccx08 engine. See the crypto/ecdsa/ecs_locl.h file for details on the ECDSA_METHOD structure
Definition: eccx08_ecdsa_sign.c:278
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_pri...
Definition: eccx08_common.c:271
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 ATECC...
Definition: eccx08_common.c:212
int eccx08_BN_encrypt(BIGNUM *number, uint8_t *iv, uint8_t *aes_key)
Encrypt a BIGNUM data using AES-256 OFB mode.
Definition: eccx08_common.c:403
int eccx08_pkey_meth_f(ENGINE *e, EVP_PKEY_METHOD **pkey_meth, const int **nids, int nid)
Initialize the EVP_PKEY_METHOD method callback for ateccx08 engine. Just returns a pointer to EVP_PKE...
Definition: eccx08_eckey_meth.c:519
const RSA_METHOD * ECCX08_RSA_meth(void)
Returns a pointer to eccx08 RSA method implementation.
Definition: eccx08_rsa_meth.c:344
EVP_PKEY * eccx08_load_privkey(ENGINE *e, const char *key_id, UI_METHOD *ui_method, void *callback_data)
Allocates the EVP_PKEY structure, decrypt the RSA private key, and load it to the allocated EVP_PKEY ...
Definition: eccx08_eckey_meth.c:69
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...
Definition: eccx08_common.c:81
int eccx08_destroy(ENGINE *e)
Deinitialize the ateccx08 engine. Destructor (complements the "ENGINE_ateccx08()" constructor) ...
Definition: engine_atecc_binder.c:190
int eccx08_finish(ENGINE *e)
Complete all functions before deinitialization of the ateccx08 engine.
Definition: engine_atecc_binder.c:215
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.
Definition: eccx08_common.c:106
int eccx08_pkey_meth_init(void)
Initialize the EVP_PKEY_METHOD method for ateccx08 engine.
Definition: eccx08_eckey_meth.c:539
int eccx08_init(ENGINE *e)
Initialization the ateccx08 engine.
Definition: engine_atecc_binder.c:202
EVP_PKEY_ASN1_METHOD eccx08_pkey_asn1_meth
eccx08_pkey_asn1_meth is an OpenSSL EVP_PKEY_ASN1_METHOD structure specific to the ateccx08 engine...
Definition: eccx08_ameth.c:249
int eccx08_rand_init(void)
Initialize the RAND method for ateccx08 engine.
Definition: eccx08_rand.c:136
int eccx08_ctrl(ENGINE *e, int cmd, long i, void *p, void(*f)())
Call a function of the ateccx08 engine depending on provided command. This is an extension of OpenSSL...
Definition: engine_atecc_binder.c:238
ECDH_METHOD eccx08_ecdh
eccx08_ecdh is an OpenSSL ECDH_METHOD structure specific to the ateccx08 engine. See the crypto/ecdh/...
Definition: eccx08_ecdh.c:378
int eccx08_cmd_defn_init(ENGINE *e)
Initialize the CMD method for ateccx08 engine.
Definition: eccx08_cmd_defns.c:429
int eccx08_pkey_asn1_meth_f(ENGINE *e, EVP_PKEY_ASN1_METHOD **pkey_meth, const int **nids, int nid)
Initialize the EVP_PKEY_ASN1_METHOD method callback for ateccx08 engine. Just returns a pointer to EV...
Definition: eccx08_ameth.c:306
EVP_PKEY * eccx08_load_pubkey(ENGINE *e, const char *key_id, UI_METHOD *ui_method, void *callback_data)
Allocates the EVP_PKEY structure and load there an ECC public key returned by the ECCX08 chip...
Definition: eccx08_eckey_meth.c:262
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...
Definition: eccx08_common.c:483
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)
Definition: eccx08_common.c:338
int eccx08_ecdh_init(uint32_t use_software)
Initialize the ECDH method for ateccx08 engine.
Definition: eccx08_ecdh.c:394
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...
Definition: eccx08_common.c:160
RAND_METHOD eccx08_rand
eccx08_rand is an OpenSSL RAND_METHOD structure specific to the ateccx08 engine. See the crypto/rand/...
Definition: eccx08_rand.c:121
int eccx08_pkey_asn1_meth_init(void)
Initialize the EVP_PKEY_ASN1_METHOD method for ateccx08 engine.
Definition: eccx08_ameth.c:327
int eccx08_cmd_ctrl(ENGINE *e, int cmd, long i, void *p, void(*f)(void))
Call a function of the ateccx08 engine depending on provided command. This is an extension of OpenSSL...
Definition: eccx08_cmd_defns.c:356