CryptoAuthLib
Microchip CryptoAuthentication Library
atca_command.c File Reference

Microchip CryptoAuthentication device command builder - this is the main object that builds the command byte strings for the given device. It does not execute the command. The basic flow is to call a command method to build the command you want given the parameters and then send that byte string through the device interface. More...

#include <stdlib.h>
#include <string.h>
#include "atca_command.h"
#include "atca_devtypes.h"

Functions

ATCA_STATUS atCheckMAC (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand CheckMAC method. More...
 
ATCA_STATUS atCounter (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand Counter method. More...
 
ATCA_STATUS atDeriveKey (ATCACommand ca_cmd, ATCAPacket *packet, bool has_mac)
 ATCACommand DeriveKey method. More...
 
ATCA_STATUS atECDH (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand ECDH method. More...
 
ATCA_STATUS atGenDig (ATCACommand ca_cmd, ATCAPacket *packet, bool is_no_mac_key)
 ATCACommand Generate Digest method. More...
 
ATCA_STATUS atGenKey (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand Generate Key method. More...
 
ATCA_STATUS atHMAC (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand HMAC method. More...
 
ATCA_STATUS atInfo (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand Info method. More...
 
ATCA_STATUS atLock (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand Lock method. More...
 
ATCA_STATUS atMAC (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand MAC method. More...
 
ATCA_STATUS atNonce (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand Nonce method. More...
 
ATCA_STATUS atPause (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand Pause method. More...
 
ATCA_STATUS atPrivWrite (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand PrivWrite method. More...
 
ATCA_STATUS atRandom (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand Random method. More...
 
ATCA_STATUS atRead (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand Read method. More...
 
ATCA_STATUS atSecureBoot (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand SecureBoot method. More...
 
ATCA_STATUS atSHA (ATCACommand ca_cmd, ATCAPacket *packet, uint16_t write_context_size)
 ATCACommand SHA method. More...
 
ATCA_STATUS atSign (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand Sign method. More...
 
ATCA_STATUS atUpdateExtra (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand UpdateExtra method. More...
 
ATCA_STATUS atVerify (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand ECDSA Verify method. More...
 
ATCA_STATUS atWrite (ATCACommand ca_cmd, ATCAPacket *packet, bool has_mac)
 ATCACommand Write method. More...
 
ATCA_STATUS atAES (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand AES method. More...
 
ATCA_STATUS atSelfTest (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand AES method. More...
 
ATCA_STATUS atKDF (ATCACommand ca_cmd, ATCAPacket *packet)
 ATCACommand KDF method. More...
 
ATCA_STATUS initATCACommand (ATCADeviceType device_type, ATCACommand ca_cmd)
 Initializer for ATCACommand. More...
 
ATCACommand newATCACommand (ATCADeviceType device_type)
 constructor for ATCACommand More...
 
void deleteATCACommand (ATCACommand *ca_cmd)
 ATCACommand destructor. More...
 
void atCRC (size_t length, const uint8_t *data, uint8_t *crc_le)
 Calculates CRC over the given raw data and returns the CRC in little-endian byte order. More...
 
void atCalcCrc (ATCAPacket *packet)
 This function calculates CRC and adds it to the correct offset in the packet data. More...
 
ATCA_STATUS atCheckCrc (const uint8_t *response)
 This function checks the consistency of a response. More...
 
bool atIsSHAFamily (ATCADeviceType device_type)
 determines if a given device type is a SHA device or a superset of a SHA device More...
 
bool atIsECCFamily (ATCADeviceType device_type)
 determines if a given device type is an ECC device or a superset of a ECC device More...
 
ATCA_STATUS isATCAError (uint8_t *data)
 checks for basic error frame in data More...
 

Detailed Description

Microchip CryptoAuthentication device command builder - this is the main object that builds the command byte strings for the given device. It does not execute the command. The basic flow is to call a command method to build the command you want given the parameters and then send that byte string through the device interface.

The primary goal of the command builder is to wrap the given parameters with the correct packet size and CRC. The caller should first fill in the parameters required in the ATCAPacket parameter given to the command. The command builder will deal with the mechanics of creating a valid packet using the parameter information.