Device interface library for multiple platforms including Mbed.

Dependents:   DeepCover Embedded Security in IoT MaximInterface MAXREFDES155#

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 Core::array_span
< uint_least8_t, 32 > 
Page
 Holds a device memory page.
typedef Core::array_span
< uint_least8_t, 8 > 
EncryptionChallenge
 Challenge for an encrypted device memory page.

Public Member Functions

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


Member Typedef Documentation

typedef Core::array_span<uint_least8_t, 8> EncryptionChallenge

Challenge for an encrypted device memory page.

Definition at line 141 of file DS28C36_DS2476.hpp.

typedef Core::array_span<uint_least8_t, 32> Page

Holds a device memory page.

Definition at line 107 of file DS28C36_DS2476.hpp.


Member Enumeration Documentation

enum ErrorValue

Device command results.

Enumerator:
InvalidResponseError 

Response does not match expected format.

Definition at line 56 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 97 of file DS28C36_DS2476.hpp.

enum KeyNum

Available keys for ECDSA operations.

Definition at line 91 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 128 of file DS28C36_DS2476.hpp.

enum PioState

Available PIO states when verifying an ECDSA signature.

Definition at line 104 of file DS28C36_DS2476.hpp.

enum SecretNum

Available secrets for HMAC operations.

Definition at line 94 of file DS28C36_DS2476.hpp.


Member Function Documentation

Result< void > authenticatedEcdsaWriteMemory ( int  pageNum,
Page::const_span  page 
)

Write with ECDSA authentication.

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

Definition at line 491 of file DS28C36_DS2476.cpp.

Result< void > 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 321 of file DS28C36_DS2476.cpp.

Result< void > authenticateEcdsaPublicKey ( bool  authWrites,
bool  ecdh,
KeyNum  keyNum,
int  csOffset,
Core::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 459 of file DS28C36_DS2476.cpp.

Result< void > 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 344 of file DS28C36_DS2476.cpp.

Result< Signature::array > computeAndReadPageAuthentication ( int  pageNum,
KeyNum  keyNum 
) const

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.
Returns:
Computed page signature.

Definition at line 246 of file DS28C36_DS2476.cpp.

Result< DS28C36::Page::array > computeAndReadPageAuthentication ( int  pageNum,
SecretNum  secretNum 
) const

Compute and read page authentication with HMAC.

Parameters:
pageNumNumber of page to authenticate.
secretNumSecret to use for authentication.
Returns:
Computed page HMAC.

Definition at line 286 of file DS28C36_DS2476.cpp.

Result< void > computeMultiblockHash ( bool  firstBlock,
bool  lastBlock,
Core::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 394 of file DS28C36_DS2476.cpp.

Result< void > decrementCounter (  )

Decrement the decrement-only counter.

Definition at line 173 of file DS28C36_DS2476.cpp.

Result< std::pair< DS28C36::EncryptionChallenge::array, DS28C36::Page::array > > encryptedReadMemory ( int  pageNum,
SecretNum  secretNum 
) const

Read memory with encryption.

Parameters:
pageNumNumber of page to read from.
secretNumSecret to use for encryption.
Returns:
Encryption challenge and encrypted page data that was read.

Definition at line 204 of file DS28C36_DS2476.cpp.

Result< void > 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 371 of file DS28C36_DS2476.cpp.

Result< std::vector< uint_least8_t > > readBuffer (  ) const

Read the temporary buffer.

Returns:
Data that was read.

Definition at line 125 of file DS28C36_DS2476.cpp.

Result< DS28C36::Page::array > readMemory ( int  pageNum ) const

Read memory with no protection.

Parameters:
pageNumNumber of page to read.
Returns:
Data that was read.

Definition at line 96 of file DS28C36_DS2476.cpp.

Result< DS28C36::PageProtection > readPageProtection ( int  pageNum ) const

Read the protection settings of a page.

Parameters:
pageNumNumber of page to read.
Returns:
Protection that was read.

Definition at line 134 of file DS28C36_DS2476.cpp.

Result< void > readRng ( Core::span< uint_least8_t >  data ) const

Read a block of random data from the RNG.

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

Definition at line 188 of file DS28C36_DS2476.cpp.

Result< void > 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 152 of file DS28C36_DS2476.cpp.

Result< void > verifyEcdsaSignature ( KeyNum  keyNum,
HashType  hashType,
Core::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 424 of file DS28C36_DS2476.cpp.

Result< void > writeBuffer ( Core::span< const uint_least8_t >  data )

Write the temporary buffer.

Parameters:
dataData to write.

Definition at line 121 of file DS28C36_DS2476.cpp.

Result< void > writeMemory ( int  pageNum,
Page::const_span  page 
)

Write memory with no protection.

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

Definition at line 75 of file DS28C36_DS2476.cpp.


Field Documentation

const int memoryPages = 32 [static]

Number of memory pages on the device.

Definition at line 88 of file DS28C36_DS2476.hpp.