OpenSSL ECC Engine  1.0
OpenSSL Engine implementation using ATECC508 for ECC key storage and ECDSA, ECDH, and RNG.
Functions | Variables
eccx08_cmd_defns.c File Reference

Implementation of OpenSSL ENGINE callback functions for certificate handling. More...

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <openssl/crypto.h>
#include <stdint.h>
#include <limits.h>
#include <assert.h>
#include <openssl/engine.h>
#include <openssl/pem.h>
#include <openssl/x509v3.h>
#include <crypto/ec/ec_lcl.h>
#include <crypto/ecdh/ech_locl.h>
#include <crypto/ecdsa/ecs_locl.h>
#include <err.h>
#include "ecc_meth.h"
#include "platform.h"

Functions

int get_device_cert (char *path)
 Retrieves pre-programmed certificates from ATECCX08 chip and saves them into temporary files as defined in the dev_cert_fname, signer_cert_fname, and root_cert_fname variables. More...
 
int get_public_key (void)
 Retrieves the signer public key from ATECCX08 chip and saves them into a global signerPubkey buffer. More...
 
int get_signer_cert (char *path)
 Retrieves pre-programmed signer certificate from ATECCX08 chip and saves it into a global signerCert buffer. More...
 
int verify_signer_cert (void)
 Verifies the signer certificate using the ATECCX08 chip hardware and data in caPubkey buffer (CA root key). More...
 
int verify_device_cert (void)
 Verifies the device certificate using the ATECCX08 chip hardware and data in signerPubkey buffer. More...
 
int get_root_cert (char *path)
 Retrieves pre-programmed CA certificate (the root) from ATECCX08 chip and saves it into a global rootCert buffer. More...
 
int extract_all_certs (char *path)
 Retrieves all pre-programmed certificates from ATECCX08 chip and saves it into a global buffers. Calls functions to verify them. More...
 
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: there is no openssl cli command to call this function. See run_engine_cmds() function from the tlsutils.c file for details. More...
 
int eccx08_cmd_defn_init (ENGINE *e)
 Initialize the CMD method for ateccx08 engine. More...
 

Variables

uint8_t signerPubkey [64] = { 0 }
 
uint8_t caPubkey [64] = { 0 }
 
uint8_t rootCert [1024] = { 0 }
 
uint8_t signerCert [1024] = { 0 }
 
uint8_t deviceCert [1024] = { 0 }
 
size_t rootCertSize = 1024
 
size_t signerCertSize = 1024
 
size_t deviceCertSize = 1024
 

Detailed Description

Implementation of OpenSSL ENGINE callback functions for certificate handling.

Copyright (c) 2015 Atmel Corporation. All rights reserved.

Function Documentation

int eccx08_cmd_ctrl ( ENGINE *  e,
int  cmd,
long  i,
void *  p,
void(*)(void)  f 
)

Call a function of the ateccx08 engine depending on provided command. This is an extension of OpenSSL: there is no openssl cli command to call this function. See run_engine_cmds() function from the tlsutils.c file for details.

Parameters
[in]ea pointer to the ENGINE structure
[in]cmda command to execute. For the full list of commands see ECCX08_CMD_* defines in the ecc_meth.h file
[in]ian integer parameter of the command
[in,out]pa string parameter of the command
[in]fa function pointer parameter of the command
Returns
1 for success
int eccx08_cmd_defn_init ( ENGINE *  e)

Initialize the CMD method for ateccx08 engine.

Parameters
[in]ea pointer to the ENGINE structure
Returns
1 for success
int extract_all_certs ( char *  path)

Retrieves all pre-programmed certificates from ATECCX08 chip and saves it into a global buffers. Calls functions to verify them.

Parameters
[in]patha pointer to a buffer with a path to the certstore
Returns
ATCA_SUCCESS for success
int get_device_cert ( char *  path)

Retrieves pre-programmed certificates from ATECCX08 chip and saves them into temporary files as defined in the dev_cert_fname, signer_cert_fname, and root_cert_fname variables.

Parameters
[in]patha pointer to a buffer with a path to the certstore
Returns
ATCA_SUCCESS for success
int get_public_key ( void  )

Retrieves the signer public key from ATECCX08 chip and saves them into a global signerPubkey buffer.

Returns
ATCA_SUCCESS for success
int get_root_cert ( char *  path)

Retrieves pre-programmed CA certificate (the root) from ATECCX08 chip and saves it into a global rootCert buffer.

Parameters
[in]patha pointer to a buffer with a path to the certstore
Returns
ATCA_SUCCESS for success
int get_signer_cert ( char *  path)

Retrieves pre-programmed signer certificate from ATECCX08 chip and saves it into a global signerCert buffer.

Parameters
[in]patha pointer to a buffer with a path to the certstore
Returns
ATCA_SUCCESS for success
int verify_device_cert ( void  )

Verifies the device certificate using the ATECCX08 chip hardware and data in signerPubkey buffer.

Returns
ATCA_SUCCESS for success
int verify_signer_cert ( void  )

Verifies the signer certificate using the ATECCX08 chip hardware and data in caPubkey buffer (CA root key).

Returns
ATCA_SUCCESS for success