CryptoAuthLib
Atmel CryptoAuthentication Library
atca_command.c File Reference

Atmel 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"

Data Structures

struct  atca_command
 atca_command is the C object backing ATCACommand. See the atca_command.h file for details on the ATCACommand methods More...
 

Functions

ATCACommand newATCACommand (ATCADeviceType device_type)
 constructor for ATCACommand More...
 
ATCA_STATUS atCheckMAC (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand CheckMAC method. More...
 
ATCA_STATUS atCounter (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand Counter method. More...
 
ATCA_STATUS atDeriveKey (ATCACommand cacmd, ATCAPacket *packet, bool hasMAC)
 ATCACommand DeriveKey method. More...
 
ATCA_STATUS atECDH (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand ECDH method. More...
 
ATCA_STATUS atGenDig (ATCACommand cacmd, ATCAPacket *packet, bool hasMACKey)
 ATCACommand Generate Digest method. More...
 
ATCA_STATUS atGenKey (ATCACommand cacmd, ATCAPacket *packet, bool isPubKey)
 ATCACommand Generate Key method. More...
 
ATCA_STATUS atHMAC (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand HMAC method. More...
 
ATCA_STATUS atInfo (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand Info method. More...
 
ATCA_STATUS atLock (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand Lock method. More...
 
ATCA_STATUS atMAC (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand MAC method. More...
 
ATCA_STATUS atNonce (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand Nonce method. More...
 
ATCA_STATUS atPause (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand Pause method. More...
 
ATCA_STATUS atPrivWrite (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand PrivWrite method. More...
 
ATCA_STATUS atRandom (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand Random method. More...
 
ATCA_STATUS atRead (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand Read method. More...
 
ATCA_STATUS atSHA (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand SHA method. More...
 
ATCA_STATUS atSign (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand Sign method. More...
 
ATCA_STATUS atUpdateExtra (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand UpdateExtra method. More...
 
ATCA_STATUS atVerify (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand ECDSA Verify method. More...
 
ATCA_STATUS atWrite (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand Write method. More...
 
ATCA_STATUS atWriteEnc (ATCACommand cacmd, ATCAPacket *packet)
 ATCACommand Write encrypted method. More...
 
void deleteATCACommand (ATCACommand *cacmd)
 ATCACommand destructor. More...
 
ATCA_STATUS atInitExecTimes (ATCACommand cacmd, ATCADeviceType device_type)
 initialize the execution times for a given device type More...
 
uint16_t atGetExecTime (ATCACommand cacmd, ATCA_CmdMap cmd)
 return the typical execution type for the given command More...
 
void atCRC (uint8_t length, uint8_t *data, uint8_t *crc)
 This function calculates CRC given raw data, puts the CRC to given pointer. More...
 
void atCalcCrc (ATCAPacket *packet)
 This function calculates CRC and adds it to the correct offset in the packet data. More...
 
uint8_t atCheckCrc (uint8_t *response)
 This function checks the consistency of a response. More...
 
bool atIsSHAFamily (ATCADeviceType deviceType)
 determines if a given device type is a SHA device or a superset of a SHA device More...
 
bool atIsECCFamily (ATCADeviceType deviceType)
 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...
 

Variables

uint16_t exectimes_x08a []
 execution times for x08a family, these are based on the typical value from the datasheet More...
 
uint16_t exectimes_204a []
 execution times for 204a, these are based on the typical value from the datasheet More...
 

Detailed Description

Atmel 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.

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