Aleksandrs Gumenuks / MaximInterface_Extended

Dependents:   mbed_DS28EC20_GPIO

Embed: (wiki syntax)

« Back to documentation index

DS28C36 Class Reference

Interface to the DS28C36 authenticator. More...

#include <DS28C36_DS2476.hpp>

Inherited by DS2476.

Data Structures

class  ComputeSecretData
 Format compute secret input data. More...
class  EncryptionHmacData
 Format encryption or decryption HMAC input data. More...
class  GpioControl
 Access fields in the GPIO Control page. More...
class  PageAuthenticationData
 Format page authentication input data. More...
class  RomOptions
 Access fields in the ROM Options page. More...
class  WriteAuthenticationData
 Format authenticated write input data. More...

Public Types

enum  ErrorValue { , InvalidResponseError = 0x101 }
 

Device command results.

More...
enum  KeyNum
 

Available keys for ECDSA operations.

More...
enum  SecretNum
 

Available secrets for HMAC operations.

More...
enum  HashType { HashInBuffer = 0, DataInBuffer = 1, THASH = 2 }
 

Data hash type when verifying an ECDSA signature.

More...
enum  PioState
 

Available PIO states when verifying an ECDSA signature.

More...
enum  PageProtectionType {
  RP = 0x01, WP = 0x02, EM = 0x04, APH = 0x08,
  EPH = 0x10, AUTH = 0x20, ECH = 0x40, ECW = 0x80
}
 

Page protection types.

More...
typedef array_span
< uint_least8_t, 32 > 
Page
 Holds a device memory page.
typedef array_span
< uint_least8_t, 8 > 
EncryptionChallenge
 Challenge for an encrypted device memory page.

Public Member Functions

MaximInterface_EXPORT error_code writeMemory (int pageNum, Page::const_span page)
 Write memory with no protection.
MaximInterface_EXPORT error_code readMemory (int pageNum, Page::span page)
 Read memory with no protection.
MaximInterface_EXPORT error_code writeBuffer (span< const uint_least8_t > data)
 Write the temporary buffer.
MaximInterface_EXPORT error_code readBuffer (std::vector< uint_least8_t > &data)
 Read the temporary buffer.
MaximInterface_EXPORT error_code readPageProtection (int pageNum, PageProtection &protection)
 Read the protection settings of a page.
MaximInterface_EXPORT error_code setPageProtection (int pageNum, const PageProtection &protection)
 Set the protection settings of a page.
MaximInterface_EXPORT error_code decrementCounter ()
 Decrement the decrement-only counter.
MaximInterface_EXPORT error_code readRng (span< uint_least8_t > data)
 Read a block of random data from the RNG.
MaximInterface_EXPORT error_code encryptedReadMemory (int pageNum, SecretNum secretNum, EncryptionChallenge::span challenge, Page::span data)
 Read memory with encryption.
MaximInterface_EXPORT error_code computeAndReadPageAuthentication (int pageNum, KeyNum keyNum, Ecc256::Signature::span signature)
 Compute and read page authentication with ECDSA.
MaximInterface_EXPORT error_code computeAndReadPageAuthentication (int pageNum, SecretNum secretNum, Sha256::Hash::span hmac)
 Compute and read page authentication with HMAC.
MaximInterface_EXPORT error_code authenticatedSha2WriteMemory (int pageNum, SecretNum secretNum, Page::const_span page)
 Write with SHA2 authentication.
MaximInterface_EXPORT error_code computeAndLockSha2Secret (int pageNum, SecretNum msecretNum, SecretNum dsecretNum, bool writeProtectEnable)
 Compute SHA2 secret and optionally lock.
MaximInterface_EXPORT error_code generateEcc256KeyPair (KeyNum keyNum, bool writeProtectEnable)
 Generate a new ECDSA key pair.
MaximInterface_EXPORT error_code computeMultiblockHash (bool firstBlock, bool lastBlock, span< const uint_least8_t > data)
 Compute a hash over multiple blocks.
MaximInterface_EXPORT error_code verifyEcdsaSignature (KeyNum keyNum, HashType hashType, Ecc256::Signature::const_span signature, PioState pioa=Unchanged, PioState piob=Unchanged)
 Verify ECDSA signature.
MaximInterface_EXPORT error_code authenticateEcdsaPublicKey (bool authWrites, bool ecdh, KeyNum keyNum, int csOffset, Ecc256::Signature::const_span signature)
 Authenticate a public key for authenticated writes or encrypted reads with ECDH.
MaximInterface_EXPORT error_code authenticatedEcdsaWriteMemory (int pageNum, Page::const_span page)
 Write with ECDSA authentication.

Static Public Attributes

static const int memoryPages = 32
 Number of memory pages on the device.
Device memory pages
static const int publicKeyAxPage = 16
static const int publicKeyAyPage = 17
static const int publicKeyBxPage = 18
static const int publicKeyByPage = 19
static const int publicKeyCxPage = 20
static const int publicKeyCyPage = 21
static const int privateKeyAPage = 22
static const int privateKeyBPage = 23
static const int privateKeyCPage = 24
static const int secretAPage = 25
static const int secretBPage = 26
static const int decrementCounterPage = 27
static const int romOptionsPage = 28
static const int gpioControlPage = 29
static const int publicKeySxPage = 30
static const int publicKeySyPage = 31

Detailed Description

Interface to the DS28C36 authenticator.

Definition at line 52 of file DS28C36_DS2476.hpp.


Member Typedef Documentation

typedef array_span<uint_least8_t, 8> EncryptionChallenge

Challenge for an encrypted device memory page.

Definition at line 140 of file DS28C36_DS2476.hpp.

typedef array_span<uint_least8_t, 32> Page

Holds a device memory page.

Definition at line 106 of file DS28C36_DS2476.hpp.


Member Enumeration Documentation

enum ErrorValue

Device command results.

Enumerator:
InvalidResponseError 

Response does not match expected format.

Definition at line 55 of file DS28C36_DS2476.hpp.

enum HashType

Data hash type when verifying an ECDSA signature.

Enumerator:
HashInBuffer 

Hash is loaded in the buffer.

DataInBuffer 

Compute hash from data loaded in the buffer.

THASH 

Use THASH from Compute Multiblock Hash command.

Definition at line 96 of file DS28C36_DS2476.hpp.

enum KeyNum

Available keys for ECDSA operations.

Definition at line 90 of file DS28C36_DS2476.hpp.

Page protection types.

Enumerator:
RP 

Read protection.

WP 

Write protection.

EM 

EPROM emulation mode.

APH 

Authentication write protection HMAC.

EPH 

Encryption and authenticated write protection HMAC.

AUTH 

Public Key C is set to authority public key.

ECH 

Encrypted read and write using shared key from ECDH.

ECW 

Authentication write protection ECDSA.

Definition at line 127 of file DS28C36_DS2476.hpp.

enum PioState

Available PIO states when verifying an ECDSA signature.

Definition at line 103 of file DS28C36_DS2476.hpp.

enum SecretNum

Available secrets for HMAC operations.

Definition at line 93 of file DS28C36_DS2476.hpp.


Member Function Documentation

error_code authenticatedEcdsaWriteMemory ( int  pageNum,
Page::const_span  page 
)

Write with ECDSA authentication.

Parameters:
pageNumNumber of page to write.
pageData to write.

Definition at line 452 of file DS28C36_DS2476.cpp.

error_code authenticatedSha2WriteMemory ( int  pageNum,
SecretNum  secretNum,
Page::const_span  page 
)

Write with SHA2 authentication.

Parameters:
pageNumNumber of page to write.
secretNumSecret to use for authentication.
pageData to write.

Definition at line 295 of file DS28C36_DS2476.cpp.

error_code authenticateEcdsaPublicKey ( bool  authWrites,
bool  ecdh,
KeyNum  keyNum,
int  csOffset,
Ecc256::Signature::const_span  signature 
)

Authenticate a public key for authenticated writes or encrypted reads with ECDH.

Parameters:
authWritesTrue to select authentication for writes.
ecdhTrue to select ECDH key exchange.
keyNumPrivate key to use for ECDH key exchange. Key A or B can be selected.
csOffsetCertificate customization field ending offset in buffer.
signatureSignature to use for authentication of public key S.

Definition at line 422 of file DS28C36_DS2476.cpp.

error_code computeAndLockSha2Secret ( int  pageNum,
SecretNum  msecretNum,
SecretNum  dsecretNum,
bool  writeProtectEnable 
)

Compute SHA2 secret and optionally lock.

Parameters:
pageNumNumber of page to use in computation.
msecretNumMaster secret to use in computation.
dsecretNumDestination secret to receive the computation result.
writeProtectEnableTrue to lock the destination secret against further writes.

Definition at line 316 of file DS28C36_DS2476.cpp.

error_code computeAndReadPageAuthentication ( int  pageNum,
KeyNum  keyNum,
Ecc256::Signature::span  signature 
)

Compute and read page authentication with ECDSA.

Parameters:
pageNumNumber of page to authenticate.
keyNumPrivate key to use for authentication. Key S cannot be used with this command.
[out]signatureComputed page signature.

Definition at line 231 of file DS28C36_DS2476.cpp.

error_code computeAndReadPageAuthentication ( int  pageNum,
SecretNum  secretNum,
Sha256::Hash::span  hmac 
)

Compute and read page authentication with HMAC.

Parameters:
pageNumNumber of page to authenticate.
secretNumSecret to use for authentication.
[out]hmacComputed page HMAC.

Definition at line 265 of file DS28C36_DS2476.cpp.

error_code computeMultiblockHash ( bool  firstBlock,
bool  lastBlock,
span< const uint_least8_t >  data 
)

Compute a hash over multiple blocks.

Parameters:
firstBlockTrue if this is the first block being hashed.
lastBlockTrue if this is the last block being hashed.
dataData block to hash. Should be 64 bytes unless this is the last block.

Definition at line 361 of file DS28C36_DS2476.cpp.

error_code decrementCounter (  )

Decrement the decrement-only counter.

Definition at line 167 of file DS28C36_DS2476.cpp.

error_code encryptedReadMemory ( int  pageNum,
SecretNum  secretNum,
EncryptionChallenge::span  challenge,
Page::span  data 
)

Read memory with encryption.

Parameters:
pageNumNumber of page to read from.
secretNumSecret to use for encryption.
[out]challengeEncryption challenge that was read.
[out]dataEncrypted page data that was read.

Definition at line 194 of file DS28C36_DS2476.cpp.

error_code generateEcc256KeyPair ( KeyNum  keyNum,
bool  writeProtectEnable 
)

Generate a new ECDSA key pair.

Parameters:
keyNumKey to generate. Key S cannot be used with this command.
writeProtectEnableTrue to lock the key against further writes.

Definition at line 340 of file DS28C36_DS2476.cpp.

error_code readBuffer ( std::vector< uint_least8_t > &  data )

Read the temporary buffer.

Parameters:
[out]dataData that was read.

Definition at line 115 of file DS28C36_DS2476.cpp.

error_code readMemory ( int  pageNum,
Page::span  page 
)

Read memory with no protection.

Parameters:
pageNumNumber of page to read.
[out]pageData that was read.

Definition at line 92 of file DS28C36_DS2476.cpp.

error_code readPageProtection ( int  pageNum,
PageProtection protection 
)

Read the protection settings of a page.

Parameters:
pageNumNumber of page to read.
[out]protectionProtection that was read.

Definition at line 130 of file DS28C36_DS2476.cpp.

error_code readRng ( span< uint_least8_t >  data )

Read a block of random data from the RNG.

Parameters:
[out]dataRandom data from RNG with length from 1 to 64.

Definition at line 180 of file DS28C36_DS2476.cpp.

error_code setPageProtection ( int  pageNum,
const PageProtection protection 
)

Set the protection settings of a page.

Parameters:
pageNumNumber of page to write.
protectionProtection to write.

Definition at line 148 of file DS28C36_DS2476.cpp.

error_code verifyEcdsaSignature ( KeyNum  keyNum,
HashType  hashType,
Ecc256::Signature::const_span  signature,
PioState  pioa = Unchanged,
PioState  piob = Unchanged 
)

Verify ECDSA signature.

Parameters:
keyNumPublic key to use for verification.
hashTypeSource of the data hash input.
signatureSignature to verify.
pioaNew state of PIOA if verification successful.
piobNew state of PIOB if verification successful.

Definition at line 389 of file DS28C36_DS2476.cpp.

error_code writeBuffer ( span< const uint_least8_t >  data )

Write the temporary buffer.

Parameters:
dataData to write.

Definition at line 111 of file DS28C36_DS2476.cpp.

error_code writeMemory ( int  pageNum,
Page::const_span  page 
)

Write memory with no protection.

Parameters:
pageNumNumber of page to write.
pageData to write.

Definition at line 73 of file DS28C36_DS2476.cpp.


Field Documentation

const int memoryPages = 32 [static]

Number of memory pages on the device.

Definition at line 87 of file DS28C36_DS2476.hpp.