Lines Matching refs:cbor

19 void eicCborInit(EicCbor* cbor, uint8_t* buffer, size_t bufferSize) {  in eicCborInit()  argument
20 eicMemSet(cbor, '\0', sizeof(EicCbor)); in eicCborInit()
21 cbor->size = 0; in eicCborInit()
22 cbor->bufferSize = bufferSize; in eicCborInit()
23 cbor->buffer = buffer; in eicCborInit()
24 cbor->digestType = EIC_CBOR_DIGEST_TYPE_SHA256; in eicCborInit()
25 eicOpsSha256Init(&cbor->digester.sha256); in eicCborInit()
28 void eicCborInitHmacSha256(EicCbor* cbor, uint8_t* buffer, size_t bufferSize, in eicCborInitHmacSha256() argument
30 eicMemSet(cbor, '\0', sizeof(EicCbor)); in eicCborInitHmacSha256()
31 cbor->size = 0; in eicCborInitHmacSha256()
32 cbor->bufferSize = bufferSize; in eicCborInitHmacSha256()
33 cbor->buffer = buffer; in eicCborInitHmacSha256()
34 cbor->digestType = EIC_CBOR_DIGEST_TYPE_HMAC_SHA256; in eicCborInitHmacSha256()
35 eicOpsHmacSha256Init(&cbor->digester.hmacSha256, hmacKey, hmacKeySize); in eicCborInitHmacSha256()
38 void eicCborEnableSecondaryDigesterSha256(EicCbor* cbor, EicSha256Ctx* sha256) { in eicCborEnableSecondaryDigesterSha256() argument
39 cbor->secondaryDigesterSha256 = sha256; in eicCborEnableSecondaryDigesterSha256()
42 void eicCborFinal(EicCbor* cbor, uint8_t digest[EIC_SHA256_DIGEST_SIZE]) { in eicCborFinal() argument
43 switch (cbor->digestType) { in eicCborFinal()
45 eicOpsSha256Final(&cbor->digester.sha256, digest); in eicCborFinal()
48 eicOpsHmacSha256Final(&cbor->digester.hmacSha256, digest); in eicCborFinal()
53 void eicCborAppend(EicCbor* cbor, const uint8_t* data, size_t size) { in eicCborAppend() argument
54 switch (cbor->digestType) { in eicCborAppend()
56 eicOpsSha256Update(&cbor->digester.sha256, data, size); in eicCborAppend()
59 eicOpsHmacSha256Update(&cbor->digester.hmacSha256, data, size); in eicCborAppend()
62 if (cbor->secondaryDigesterSha256 != NULL) { in eicCborAppend()
63 eicOpsSha256Update(cbor->secondaryDigesterSha256, data, size); in eicCborAppend()
66 if (cbor->size >= cbor->bufferSize) { in eicCborAppend()
67 cbor->size += size; in eicCborAppend()
71 size_t numBytesLeft = cbor->bufferSize - cbor->size; in eicCborAppend()
76 eicMemCpy(cbor->buffer + cbor->size, data, numBytesToCopy); in eicCborAppend()
78 cbor->size += size; in eicCborAppend()
94 void eicCborBegin(EicCbor* cbor, int majorType, uint64_t size) { in eicCborBegin() argument
99 eicCborAppend(cbor, data, 1); in eicCborBegin()
103 eicCborAppend(cbor, data, 2); in eicCborBegin()
108 eicCborAppend(cbor, data, 3); in eicCborBegin()
115 eicCborAppend(cbor, data, 5); in eicCborBegin()
126 eicCborAppend(cbor, data, 9); in eicCborBegin()
130 void eicCborAppendByteString(EicCbor* cbor, const uint8_t* data, size_t dataSize) { in eicCborAppendByteString() argument
131 eicCborBegin(cbor, EIC_CBOR_MAJOR_TYPE_BYTE_STRING, dataSize); in eicCborAppendByteString()
132 eicCborAppend(cbor, data, dataSize); in eicCborAppendByteString()
135 void eicCborAppendString(EicCbor* cbor, const char* str, size_t strLength) { in eicCborAppendString() argument
136 eicCborBegin(cbor, EIC_CBOR_MAJOR_TYPE_STRING, strLength); in eicCborAppendString()
137 eicCborAppend(cbor, (const uint8_t*)str, strLength); in eicCborAppendString()
140 void eicCborAppendStringZ(EicCbor* cbor, const char* str) { in eicCborAppendStringZ() argument
141 eicCborAppendString(cbor, str, eicStrLen(str)); in eicCborAppendStringZ()
144 void eicCborAppendSimple(EicCbor* cbor, uint8_t simpleValue) { in eicCborAppendSimple() argument
145 eicCborBegin(cbor, EIC_CBOR_MAJOR_TYPE_SIMPLE, simpleValue); in eicCborAppendSimple()
148 void eicCborAppendBool(EicCbor* cbor, bool value) { in eicCborAppendBool() argument
150 eicCborAppendSimple(cbor, simpleValue); in eicCborAppendBool()
153 void eicCborAppendSemantic(EicCbor* cbor, uint64_t value) { in eicCborAppendSemantic() argument
155 eicCborBegin(cbor, EIC_CBOR_MAJOR_TYPE_SEMANTIC, encoded); in eicCborAppendSemantic()
158 void eicCborAppendUnsigned(EicCbor* cbor, uint64_t value) { in eicCborAppendUnsigned() argument
160 eicCborBegin(cbor, EIC_CBOR_MAJOR_TYPE_UNSIGNED, encoded); in eicCborAppendUnsigned()
163 void eicCborAppendNumber(EicCbor* cbor, int64_t value) { in eicCborAppendNumber() argument
166 eicCborBegin(cbor, EIC_CBOR_MAJOR_TYPE_NEGATIVE, encoded); in eicCborAppendNumber()
168 eicCborAppendUnsigned(cbor, value); in eicCborAppendNumber()
172 void eicCborAppendArray(EicCbor* cbor, size_t numElements) { in eicCborAppendArray() argument
173 eicCborBegin(cbor, EIC_CBOR_MAJOR_TYPE_ARRAY, numElements); in eicCborAppendArray()
176 void eicCborAppendMap(EicCbor* cbor, size_t numPairs) { in eicCborAppendMap() argument
177 eicCborBegin(cbor, EIC_CBOR_MAJOR_TYPE_MAP, numPairs); in eicCborAppendMap()