5 #ifndef OPENTITAN_SW_DEVICE_LIB_CRYPTO_INCLUDE_DATATYPES_H_
6 #define OPENTITAN_SW_DEVICE_LIB_CRYPTO_INCLUDE_DATATYPES_H_
11 #ifdef OTCRYPTO_IN_REPO
13 #include "sw/device/lib/base/status.h"
15 #include "freestanding/absl_status.h"
16 #include "freestanding/defs.h"
71 kOtcryptoStatusValueOk = (int32_t)0x739,
73 kOtcryptoStatusValueBadArgs = (int32_t)0x8000fea0 | kInvalidArgument,
75 kOtcryptoStatusValueInternalError = (int32_t)0x80005340 | kAborted,
77 kOtcryptoStatusValueFatalError = (int32_t)0x80006d80 | kFailedPrecondition,
79 kOtcryptoStatusValueAsyncIncomplete = (int32_t)0x8000ea40 | kUnavailable,
82 kOtcryptoStatusValueNotImplemented = (int32_t)0x80008d20 | kUnimplemented,
109 const uint8_t *
const data;
138 const uint32_t *
const data;
150 kOtcryptoKeyTypeAes = 0x8e9,
152 kOtcryptoKeyTypeHmac = 0xe3f,
154 kOtcryptoKeyTypeKmac = 0xb74,
156 kOtcryptoKeyTypeRsa = 0x7ee,
158 kOtcryptoKeyTypeEcc = 0x15b,
160 kOtcryptoKeyTypeKdf = 0xb87,
173 kOtcryptoAesKeyModeEcb = 0x1b6,
175 kOtcryptoAesKeyModeCbc = 0xf3a,
177 kOtcryptoAesKeyModeCfb = 0x0f9,
179 kOtcryptoAesKeyModeOfb = 0xb49,
181 kOtcryptoAesKeyModeCtr = 0x4ce,
183 kOtcryptoAesKeyModeGcm = 0xaa5,
185 kOtcryptoAesKeyModeKwp = 0x7d5,
198 kOtcryptoHmacKeyModeSha256 = 0x7fd,
200 kOtcryptoHmacKeyModeSha384 = 0x43b,
202 kOtcryptoHmacKeyModeSha512 = 0x7a2,
215 kOtcryptoKmacKeyModeKmac128 = 0xa56,
217 kOtcryptoKmacKeyModeKmac256 = 0x663,
230 kOtcryptoRsaKeyModeSignPkcs = 0x3d4,
232 kOtcryptoRsaKeyModeSignPss = 0x761,
234 kOtcryptoRsaKeyModeEncryptOaep = 0x585,
247 kOtcryptoEccKeyModeEcdsaP256 = 0x31e,
249 kOtcryptoEccKeyModeEcdsaP384 = 0x695,
251 kOtcryptoEccKeyModeEcdhP256 = 0x5fc,
253 kOtcryptoEccKeyModeEcdhP384 = 0x1c7,
255 kOtcryptoEccKeyModeEd25519 = 0x663,
257 kOtcryptoEccKeyModeX25519 = 0x0bb,
270 kOtcryptoKdfKeyModeCtrHmac = 0x12f,
272 kOtcryptoKdfKeyModeKmac128 = 0xe5e,
274 kOtcryptoKdfKeyModeKmac256 = 0x353,
288 kOtcryptoKeyModeAesEcb = kOtcryptoKeyTypeAes << 16 | kOtcryptoAesKeyModeEcb,
290 kOtcryptoKeyModeAesCbc = kOtcryptoKeyTypeAes << 16 | kOtcryptoAesKeyModeCbc,
292 kOtcryptoKeyModeAesCfb = kOtcryptoKeyTypeAes << 16 | kOtcryptoAesKeyModeCfb,
294 kOtcryptoKeyModeAesOfb = kOtcryptoKeyTypeAes << 16 | kOtcryptoAesKeyModeOfb,
296 kOtcryptoKeyModeAesCtr = kOtcryptoKeyTypeAes << 16 | kOtcryptoAesKeyModeCtr,
298 kOtcryptoKeyModeAesGcm = kOtcryptoKeyTypeAes << 16 | kOtcryptoAesKeyModeGcm,
300 kOtcryptoKeyModeAesKwp = kOtcryptoKeyTypeAes << 16 | kOtcryptoAesKeyModeKwp,
302 kOtcryptoKeyModeHmacSha256 =
303 kOtcryptoKeyTypeHmac << 16 | kOtcryptoHmacKeyModeSha256,
305 kOtcryptoKeyModeHmacSha384 =
306 kOtcryptoKeyTypeHmac << 16 | kOtcryptoHmacKeyModeSha384,
308 kOtcryptoKeyModeHmacSha512 =
309 kOtcryptoKeyTypeHmac << 16 | kOtcryptoHmacKeyModeSha512,
311 kOtcryptoKeyModeKmac128 =
312 kOtcryptoKeyTypeKmac << 16 | kOtcryptoKmacKeyModeKmac128,
314 kOtcryptoKeyModeKmac256 =
315 kOtcryptoKeyTypeKmac << 16 | kOtcryptoKmacKeyModeKmac256,
317 kOtcryptoKeyModeRsaSignPkcs =
318 kOtcryptoKeyTypeRsa << 16 | kOtcryptoRsaKeyModeSignPkcs,
320 kOtcryptoKeyModeRsaSignPss =
321 kOtcryptoKeyTypeRsa << 16 | kOtcryptoRsaKeyModeSignPss,
323 kOtcryptoKeyModeRsaEncryptOaep =
324 kOtcryptoKeyTypeRsa << 16 | kOtcryptoRsaKeyModeEncryptOaep,
326 kOtcryptoKeyModeEcdsaP256 =
327 kOtcryptoKeyTypeEcc << 16 | kOtcryptoEccKeyModeEcdsaP256,
329 kOtcryptoKeyModeEcdsaP384 =
330 kOtcryptoKeyTypeEcc << 16 | kOtcryptoEccKeyModeEcdsaP384,
332 kOtcryptoKeyModeEcdhP256 =
333 kOtcryptoKeyTypeEcc << 16 | kOtcryptoEccKeyModeEcdhP256,
335 kOtcryptoKeyModeEcdhP384 =
336 kOtcryptoKeyTypeEcc << 16 | kOtcryptoEccKeyModeEcdhP384,
338 kOtcryptoKeyModeEd25519 =
339 kOtcryptoKeyTypeEcc << 16 | kOtcryptoEccKeyModeEd25519,
341 kOtcryptoKeyModeX25519 =
342 kOtcryptoKeyTypeEcc << 16 | kOtcryptoEccKeyModeX25519,
344 kOtcryptoKeyModeKdfCtrHmac =
345 kOtcryptoKeyTypeKdf << 16 | kOtcryptoKdfKeyModeCtrHmac,
347 kOtcryptoKeyModeKdfKmac128 =
348 kOtcryptoKeyTypeKdf << 16 | kOtcryptoKdfKeyModeKmac128,
350 kOtcryptoKeyModeKdfKmac256 =
351 kOtcryptoKeyTypeKdf << 16 | kOtcryptoKdfKeyModeKmac256,
368 kOtcryptoKeySecurityLevelLow = 0x1e9,
370 kOtcryptoKeySecurityLevelMedium = 0xeab,
372 kOtcryptoKeySecurityLevelHigh = 0xa7e,
387 kOtcryptoLibVersion1 = 0x7f4,
431 const size_t keyblob_length;
445 kOtcryptoHashModeSha256 = 0x69b,
447 kOtcryptoHashModeSha384 = 0x7ae,
449 kOtcryptoHashModeSha512 = 0x171,
451 kOtcryptoHashModeSha3_224 = 0x516,
453 kOtcryptoHashModeSha3_256 = 0x2d4,
455 kOtcryptoHashModeSha3_384 = 0x267,
457 kOtcryptoHashModeSha3_512 = 0x44d,
459 kOtcryptoHashXofModeShake128 = 0x5d8,
461 kOtcryptoHashXofModeShake256 = 0x34a,
463 kOtcryptoHashXofModeCshake128 = 0x0bd,
465 kOtcryptoHashXofModeCshake256 = 0x4e2,