Mistake on this page? Email us
pal_Crypto.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // Copyright 2016-2019 ARM Ltd.
3 //
4 // SPDX-License-Identifier: Apache-2.0
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 // ----------------------------------------------------------------------------
18 
19 #ifndef _PAL_CRYPTO_H_
20 #define _PAL_CRYPTO_H_
21 
22 #ifndef _PAL_H
23  #error "Please do not include this file directly, use pal.h instead"
24 #endif
25 
37 typedef uintptr_t palAesHandle_t;
38 typedef uintptr_t palX509Handle_t;
39 typedef uintptr_t palMDHandle_t;
40 typedef uintptr_t palCCMHandle_t;
41 typedef uintptr_t palCMACHandle_t;
42 typedef uintptr_t palCtrDrbgCtxHandle_t;
43 typedef uintptr_t palCurveHandle_t;
44 typedef uintptr_t palGroupIDHandle_t;
45 typedef uintptr_t palECKeyHandle_t;
46 typedef uintptr_t palSignatureHandle_t;
47 typedef uintptr_t palx509CSRHandle_t;
48 typedef uintptr_t palKeyHandle_t;
49 
51 typedef enum palAesKeyType{
55 
57 typedef enum palMDType{
60 
62 typedef enum palAesMode{
66 
68 typedef enum palASNTag{
73  PAL_ASN1_NULL = 0x05,
74  PAL_ASN1_OID = 0x06,
77  PAL_ASN1_SET = 0x11,
89 
90 #define PAL_ASN1_CLASS_BITS 0xC0
91 #define PAL_ASN1_TAG_BITS 0x1F
92 #define PAL_CRYPT_BLOCK_SIZE 16
93 #define PAL_SHA256_SIZE 32
94 #define PAL_ECDSA_SECP256R1_SIGNATURE_RAW_SIZE 64
95 #define PAL_SECP256R1_MAX_PUB_KEY_RAW_SIZE 65
96 #define PAL_ECDSA_SECP256R1_SIGNATURE_DER_SIZE 74
97 #define PAL_EC_SECP256R1_MAX_PUB_KEY_DER_SIZE 91
98 #define PAL_SECP256R1_RAW_KEY_AGREEMENT_SIZE 32
99 
100 typedef enum palFormat{
102  /*PAL_POINT_CONVERSION_COMPRESSED*/
103 }palFormat_t;
104 
105 typedef enum palCipherID{
107  /*PAL_CIPHER_ID_DES*/
109 
111 typedef enum palGroupIndex{
115 
117 typedef enum palKeyUsage{
123 
125 typedef enum palExtKeyUsage {
134 
136 typedef enum palKeyToCheck{
141 
143 typedef enum palX509Attr{
154 
155 #ifndef MBED_CONF_MBED_CLOUD_CLIENT_PSA_SUPPORT
156 typedef struct palCryptoBuffer{
158  uint8_t* buffer;
159  uint32_t size;
161 #endif //MBED_CONF_MBED_CLOUD_CLIENT_PSA_SUPPORT
162 
163 
164 /***************************************************/
165 /**** PAL Crypto Client APIs ***********************/
166 /***************************************************/
167 
175 
183 
193 palStatus_t pal_setAesKey(palAesHandle_t aes, const unsigned char* key, uint32_t keybits, palAesKeyType_t keyTarget);
194 
209 palStatus_t pal_aesCTR(palAesHandle_t aes, const unsigned char* input, unsigned char* output, size_t inLen, unsigned char iv[16]);
210 
225 palStatus_t pal_aesCTRWithZeroOffset(palAesHandle_t aes, const unsigned char* input, unsigned char* output, size_t inLen, unsigned char iv[16]);
226 
236 palStatus_t pal_aesECB(palAesHandle_t aes, const unsigned char input[PAL_CRYPT_BLOCK_SIZE], unsigned char output[PAL_CRYPT_BLOCK_SIZE], palAesMode_t mode);
237 
246 palStatus_t pal_sha256(const unsigned char* input, size_t inLen, unsigned char output[PAL_SHA256_SIZE]);
247 
255 
264 palStatus_t pal_x509CertParse(palX509Handle_t x509Cert, const unsigned char* input, size_t inLen);
265 
278 palStatus_t pal_x509CertGetAttribute(palX509Handle_t x509Cert, palX509Attr_t attr, void* output, size_t outLenBytes, size_t* actualOutLenBytes);
279 
294 
303 palStatus_t pal_x509CertVerifyExtended(palX509Handle_t x509Cert, palX509Handle_t x509CertChain, int32_t* verifyResult);
304 
314 
322 
331 
340 palStatus_t pal_mdUpdate(palMDHandle_t md, const unsigned char* input, size_t inLen);
341 
350 palStatus_t pal_mdGetOutputSize(palMDHandle_t md, size_t* bufferSize);
351 
360 palStatus_t pal_mdFinal(palMDHandle_t md, unsigned char* output);
361 
369 
381 palStatus_t pal_verifySignature(palX509Handle_t x509, palMDType_t mdType, const unsigned char *hash, size_t hashLen, const unsigned char *sig, size_t sigLen);
382 
394 palStatus_t pal_ASN1GetTag(unsigned char **position, const unsigned char *end, size_t *len, uint8_t tag);
395 
403 
411 
421 palStatus_t pal_CCMSetKey(palCCMHandle_t ctx, const unsigned char *key, uint32_t keybits, palCipherID_t id);
422 
438 palStatus_t pal_CCMDecrypt(palCCMHandle_t ctx, unsigned char* input, size_t inLen,
439  unsigned char* iv, size_t ivLen, unsigned char* add,
440  size_t addLen, unsigned char* tag, size_t tagLen,
441  unsigned char* output);
442 
458 palStatus_t pal_CCMEncrypt(palCCMHandle_t ctx, unsigned char* input,
459  size_t inLen, unsigned char* iv, size_t ivLen,
460  unsigned char* add, size_t addLen, unsigned char* output,
461  unsigned char* tag, size_t tagLen);
462 
471 palStatus_t pal_CtrDRBGInit(palCtrDrbgCtxHandle_t* ctx, const void* seed, size_t len);
472 
484 
493 palStatus_t pal_CtrDRBGGenerate(palCtrDrbgCtxHandle_t ctx, unsigned char* out, size_t len);
494 
502 
503 
515 palStatus_t pal_cipherCMAC(const unsigned char *key, size_t keyLenInBits, const unsigned char *input, size_t inputLenInBytes, unsigned char *output);
516 
526 palStatus_t pal_CMACStart(palCMACHandle_t *ctx, const unsigned char *key, size_t keyLenBits, palCipherID_t cipherID);
527 
536 palStatus_t pal_CMACUpdate(palCMACHandle_t ctx, const unsigned char *input, size_t inLen);
537 
546 palStatus_t pal_CMACFinish(palCMACHandle_t *ctx, unsigned char *output, size_t* outLen);
547 
559 palStatus_t pal_mdHmacSha256(const unsigned char *key, size_t keyLenInBytes, const unsigned char *input, size_t inputLenInBytes, unsigned char *output, size_t* outputLenInBytes);
560 
561 
572 palStatus_t pal_ECCheckKey(palCurveHandle_t grp, palECKeyHandle_t key, uint32_t type, bool *verified);
573 
581 
590 
598 palStatus_t pal_newKeyHandle( palKeyHandle_t *keyHandle, size_t key_size);
599 
600 
608 
609 
618 palStatus_t pal_parseECPrivateKeyFromDER(const unsigned char* prvDERKey, size_t keyLen, palECKeyHandle_t key);
619 
628 palStatus_t pal_parseECPublicKeyFromDER(const unsigned char* pubDERKey, size_t keyLen, palECKeyHandle_t key);
629 
630 
639 
648 
660  const unsigned char *rawSignature,
661  size_t rawSignatureSize,
662  unsigned char *derSignatureOut,
663  size_t derSignatureMaxSize,
664  size_t *derSignatureActSizeOut);
665 
680 palStatus_t pal_asymmetricSign(const palECKeyHandle_t privateKeyHanlde, palMDType_t mdType, const unsigned char *hash, size_t hashSize, unsigned char *outSignature, size_t maxSignatureSize, size_t *actualOutSignatureSize);
681 
695 palStatus_t pal_asymmetricVerify(const palECKeyHandle_t publicKeyHanlde, palMDType_t mdType, const unsigned char *hash, size_t hashSize, const unsigned char *signature, size_t signatureSize);
696 
697 
698 #ifndef MBED_CONF_MBED_CLOUD_CLIENT_PSA_SUPPORT
699 
707 
708 
717 #endif
718 
728 palStatus_t pal_writePrivateKeyToDer(palECKeyHandle_t key, unsigned char* derBuffer, size_t bufferSize, size_t* actualSize);
729 
739 palStatus_t pal_writePublicKeyToDer(palECKeyHandle_t key, unsigned char* derBuffer, size_t bufferSize, size_t* actualSize);
740 
750 
759 
768 
776 
784 
792 palStatus_t pal_x509CSRSetSubject(palx509CSRHandle_t x509CSR, const char* subjectName);
793 
802 
813 
821 palStatus_t pal_x509CSRSetKeyUsage(palx509CSRHandle_t x509CSR, uint32_t keyUsage);
822 
830 palStatus_t pal_x509CSRSetExtendedKeyUsage(palx509CSRHandle_t x509CSR, uint32_t extKeyUsage);
831 
842 palStatus_t pal_x509CSRSetExtension(palx509CSRHandle_t x509CSR,const char* oid, size_t oidLen,
843  const unsigned char* value, size_t valueLen);
844 
854 palStatus_t pal_x509CSRWriteDER(palx509CSRHandle_t x509CSR, unsigned char* derBuf, size_t derBufLen, size_t* actualDerLen);
855 
866 palStatus_t pal_x509CSRFromCertWriteDER(palX509Handle_t x509Cert, palx509CSRHandle_t x509CSR, unsigned char* derBuf, size_t derBufLen, size_t* actualDerBufLen);
867 
875 
885 palStatus_t pal_ECDHComputeKey(const palCurveHandle_t grp, const palECKeyHandle_t peerPublicKey,
886  const palECKeyHandle_t privateKey, palECKeyHandle_t outKey);
887 
900  const uint8_t *derPeerPublicKey,
901  size_t derPeerPublicKeySize,
902  const palECKeyHandle_t privateKeyHandle,
903  unsigned char *rawSharedSecretOut,
904  size_t rawSharedSecretMaxSize,
905  size_t *rawSharedSecretActSizeOut);
906 
919 palStatus_t pal_ECDSASign(palCurveHandle_t grp, palMDType_t mdType, palECKeyHandle_t prvKey, unsigned char* dgst,
920  uint32_t dgstLen, unsigned char *sig, size_t *sigLen);
921 
934 palStatus_t pal_ECDSAVerify(palECKeyHandle_t pubKey, unsigned char* dgst, uint32_t dgstLen,
935  unsigned char* sig, size_t sigLen, bool* verified);
936 
937 
951 palStatus_t pal_x509CertGetHTBS(palX509Handle_t x509Cert, palMDType_t hash_type, unsigned char *output, size_t outLenBytes, size_t* actualOutLenBytes);
952 
953 #endif //_PAL_CRYPTO_H_
palStatus_t pal_ECKeyFree(palECKeyHandle_t *key)
Release a private or public key context from memory.
Definition: pal_Crypto.h:126
Definition: pal_Crypto.h:112
palStatus_t pal_x509CertVerify(palX509Handle_t x509Cert, palX509Handle_t x509CertChain)
Verify one or more DER encoded X.509 certificates.
enum palGroupIndex palGroupIndex_t
Supported curves.
enum palMDType palMDType_t
Message digest algorithms supported by PAL.
enum palKeyUsage palKeyUsage_t
Key usage options.
Definition: pal_Crypto.h:82
palStatus_t pal_mdUpdate(palMDHandle_t md, const unsigned char *input, size_t inLen)
Apply an Message Digest (MD) process on a buffer.
palStatus_t pal_ECDHComputeKey(const palCurveHandle_t grp, const palECKeyHandle_t peerPublicKey, const palECKeyHandle_t privateKey, palECKeyHandle_t outKey)
Compute the shared secret using elliptic curve Diffie–Hellman.
palStatus_t pal_parseECPrivateKeyFromDER(const unsigned char *prvDERKey, size_t keyLen, palECKeyHandle_t key)
Parse a DER-encoded private key.
palStatus_t pal_mdFree(palMDHandle_t *md)
Free and clear a Message Digest (MD) context.
enum palAesKeyType palAesKeyType_t
Key types to be set to the AES engine.
palAesMode
AES mode for ECB encryption and decryption.
Definition: pal_Crypto.h:62
palStatus_t pal_x509CertParse(palX509Handle_t x509Cert, const unsigned char *input, size_t inLen)
Parse one or more certificates and add them to the chained list.
palStatus_t pal_mdFinal(palMDHandle_t md, unsigned char *output)
Calculate the final Message Digest (MD).
Definition: pal_Crypto.h:121
Definition: pal_Crypto.h:144
Definition: pal_Crypto.h:52
Definition: pal_Crypto.h:87
palKeyToCheck
Key check options.
Definition: pal_Crypto.h:136
palStatus_t pal_mdInit(palMDHandle_t *md, palMDType_t mdType)
Initialize the Message Digest (MD) context and set it up according to the given algorithm.
palStatus_t pal_CtrDRBGIsSeeded(palCtrDrbgCtxHandle_t ctx)
Check whether a Counter mode Deterministic Random Byte Generator (CTR-DRBG) context is seeded...
Definition: pal_Crypto.h:73
Definition: pal_Crypto.h:71
uint32_t size
Definition: pal_Crypto.h:159
uintptr_t palSignatureHandle_t
Definition: pal_Crypto.h:46
palStatus_t pal_aesCTRWithZeroOffset(palAesHandle_t aes, const unsigned char *input, unsigned char *output, size_t inLen, unsigned char iv[16])
Use AES-CTR encryption or decryption with zero offset on a buffer.
Definition: pal_Crypto.h:79
#define PAL_CRYPT_BLOCK_SIZE
Definition: pal_Crypto.h:92
Definition: pal_Crypto.h:80
Definition: pal_Crypto.h:148
palStatus_t pal_ECKeyGenerateKey(palGroupIndex_t grpID, palECKeyHandle_t key)
Generate a key pair for a given Elliptic Curve.
palStatus_t pal_ECGroupInitAndLoad(palCurveHandle_t *grp, palGroupIndex_t index)
Initialize and set an ECP group using well-known domain parameters.
Definition: pal_Crypto.h:75
palStatus_t pal_CMACStart(palCMACHandle_t *ctx, const unsigned char *key, size_t keyLenBits, palCipherID_t cipherID)
Start an iterative CMAC cipher.
Definition: pal_Crypto.h:127
palCipherID
Definition: pal_Crypto.h:105
palStatus_t pal_ASN1GetTag(unsigned char **position, const unsigned char *end, size_t *len, uint8_t tag)
Check for a tag in ASN.1 data.
palStatus_t pal_asymmetricSign(const palECKeyHandle_t privateKeyHanlde, palMDType_t mdType, const unsigned char *hash, size_t hashSize, unsigned char *outSignature, size_t maxSignatureSize, size_t *actualOutSignatureSize)
Compute the Elliptic Curve Digital Signature Algorithm (ECDSA) raw signature of a previously hashed m...
enum palX509Attr palX509Attr_t
Attributes to be retrieved from the X.509 certificate.
Definition: pal_Crypto.h:145
palStatus_t pal_freeKeyHandle(palKeyHandle_t *keyHandle)
frees a a key handle.
palStatus_t pal_x509CSRSetExtendedKeyUsage(palx509CSRHandle_t x509CSR, uint32_t extKeyUsage)
Set the extended key usage flags.
palStatus_t pal_x509CSRSetMD(palx509CSRHandle_t x509CSR, palMDType_t mdType)
palStatus_t pal_x509CSRSetSubject(palx509CSRHandle_t x509CSR, const char *subjectName)
Set the subject name for a certificate signing request (CSR). Subject names should contain a comma-se...
Definition: pal_Crypto.h:118
Definition: pal_Crypto.h:138
palStatus_t pal_x509CSRSetExtension(palx509CSRHandle_t x509CSR, const char *oid, size_t oidLen, const unsigned char *value, size_t valueLen)
Generic function to extend a CSR context.
palStatus_t pal_verifySignature(palX509Handle_t x509, palMDType_t mdType, const unsigned char *hash, size_t hashLen, const unsigned char *sig, size_t sigLen)
Verify the signature.
palStatus_t pal_x509CertGetHTBS(palX509Handle_t x509Cert, palMDType_t hash_type, unsigned char *output, size_t outLenBytes, size_t *actualOutLenBytes)
Calculate the hash of the part of an X.509 certificate that is to be signed.
Crypto buffer structure.
Definition: pal_Crypto.h:157
Definition: pal_Crypto.h:101
palAesKeyType
Key types to be set to the AES engine.
Definition: pal_Crypto.h:51
palStatus_t pal_initAes(palAesHandle_t *aes)
Initialize an AES context.
palStatus_t pal_ECKeyGetCurve(palECKeyHandle_t key, palGroupIndex_t *grpID)
Retrieve the curve ID if it exists in the given key.
enum palASNTag palASNTag_t
The enum tags supported by PAL for ASN.1.
palKeyUsage
Key usage options.
Definition: pal_Crypto.h:117
palStatus_t pal_CCMInit(palCCMHandle_t *ctx)
uintptr_t palGroupIDHandle_t
Definition: pal_Crypto.h:44
palStatus_t pal_writePrivateKeyToDer(palECKeyHandle_t key, unsigned char *derBuffer, size_t bufferSize, size_t *actualSize)
DER encode a private key from a key handle.
palStatus_t pal_parseECPublicKeyFromHandle(const palKeyHandle_t pubKeyHandle, palECKeyHandle_t ECKeyHandle)
Parse a public key.
palX509Attr
Attributes to be retrieved from the X.509 certificate.
Definition: pal_Crypto.h:143
palStatus_t pal_x509CertCheckExtendedKeyUsage(palX509Handle_t x509Cert, palExtKeyUsage_t usage)
Definition: pal_Crypto.h:151
uintptr_t palAesHandle_t
Definition: pal_Crypto.h:37
Definition: pal_Crypto.h:106
struct palCryptoBuffer palCryptoBuffer_t
Crypto buffer structure.
palStatus_t pal_ECCheckKey(palCurveHandle_t grp, palECKeyHandle_t key, uint32_t type, bool *verified)
Check that the private key, public key, or both are valid and that the public key is on the curve...
Definition: pal_Crypto.h:131
palStatus_t pal_ECGroupFree(palCurveHandle_t *grp)
Free the ECP group context.
Definition: pal_Crypto.h:81
Definition: pal_Crypto.h:86
Definition: pal_Crypto.h:113
Definition: pal_Crypto.h:85
palStatus_t pal_CtrDRBGFree(palCtrDrbgCtxHandle_t *ctx)
Destroy a Counter mode Deterministic Random Byte Generator (CTR-DRBG) context.
palStatus_t pal_x509CSRInit(palx509CSRHandle_t *x509CSR)
Allocate and initialize X.509 certificate signing request (CSR) context.
Definition: pal_Crypto.h:77
uintptr_t palMDHandle_t
Definition: pal_Crypto.h:39
Definition: pal_Crypto.h:139
enum palCipherID palCipherID_t
palASNTag
The enum tags supported by PAL for ASN.1.
Definition: pal_Crypto.h:68
Definition: pal_Crypto.h:129
Definition: pal_Crypto.h:149
Definition: pal_Crypto.h:84
palStatus_t pal_aesECB(palAesHandle_t aes, const unsigned char input[PAL_CRYPT_BLOCK_SIZE], unsigned char output[PAL_CRYPT_BLOCK_SIZE], palAesMode_t mode)
Use AES-ECB encryption or decryption on a block.
palStatus_t pal_ECDHKeyAgreement(const uint8_t *derPeerPublicKey, size_t derPeerPublicKeySize, const palECKeyHandle_t privateKeyHandle, unsigned char *rawSharedSecretOut, size_t rawSharedSecretMaxSize, size_t *rawSharedSecretActSizeOut)
Compute the raw shared secret using elliptic curve Diffie–Hellman.
palStatus_t pal_x509CSRSetKey(palx509CSRHandle_t x509CSR, palECKeyHandle_t pubKey, palECKeyHandle_t prvKey)
Set the key for a CSR.
Definition: pal_Crypto.h:137
enum palFormat palFormat_t
Definition: pal_Crypto.h:146
uintptr_t palX509Handle_t
Definition: pal_Crypto.h:38
palStatus_t pal_x509CertVerifyExtended(palX509Handle_t x509Cert, palX509Handle_t x509CertChain, int32_t *verifyResult)
Verify one or more DER-encoded X.509 certificates.
Definition: pal_Crypto.h:70
palStatus_t pal_CtrDRBGInit(palCtrDrbgCtxHandle_t *ctx, const void *seed, size_t len)
Initialize a Counter mode Deterministic Random Byte Generator (CTR-DRBG) context with a given seed...
palStatus_t pal_newKeyHandle(palKeyHandle_t *keyHandle, size_t key_size)
Initializes a handle to key according to its size.
palStatus_t pal_x509CSRWriteDER(palx509CSRHandle_t x509CSR, unsigned char *derBuf, size_t derBufLen, size_t *actualDerLen)
Write a CSR to a DER structure.
Definition: pal_Crypto.h:58
palFormat
Definition: pal_Crypto.h:100
enum palKeyToCheck palKeyToCheck_t
Key check options.
Definition: pal_Crypto.h:64
Definition: pal_Crypto.h:63
palStatus_t pal_cipherCMAC(const unsigned char *key, size_t keyLenInBits, const unsigned char *input, size_t inputLenInBytes, unsigned char *output)
Apply a one-shot CMAC cipher.
uintptr_t palCMACHandle_t
Definition: pal_Crypto.h:41
palStatus_t pal_x509Free(palX509Handle_t *x509Cert)
Deallocate all certificate data.
palStatus_t pal_x509CSRFromCertWriteDER(palX509Handle_t x509Cert, palx509CSRHandle_t x509CSR, unsigned char *derBuf, size_t derBufLen, size_t *actualDerBufLen)
Writes a CSR from a given X.509 Certificate.
Definition: pal_Crypto.h:78
Definition: pal_Crypto.h:128
Definition: pal_Crypto.h:152
palStatus_t pal_writePublicKeyToDer(palECKeyHandle_t key, unsigned char *derBuffer, size_t bufferSize, size_t *actualSize)
DER encode a public key from a key handle.
Definition: pal_Crypto.h:72
palStatus_t pal_mdGetOutputSize(palMDHandle_t md, size_t *bufferSize)
Get the length of the Message Digest (MD) output.
Definition: pal_Crypto.h:74
palStatus_t pal_CMACUpdate(palCMACHandle_t ctx, const unsigned char *input, size_t inLen)
Update an iterative CMAC cipher.
Definition: pal_Crypto.h:120
Definition: pal_Crypto.h:147
#define PAL_SHA256_SIZE
Definition: pal_Crypto.h:93
uintptr_t palCtrDrbgCtxHandle_t
Definition: pal_Crypto.h:42
palStatus_t pal_CCMFree(palCCMHandle_t *ctx)
Destroy a CCM context.
palStatus_t pal_writePublicKeyWithHandle(const palKeyHandle_t pubKeyHandle, palECKeyHandle_t ECKeyHandle)
Write a public key from a key handle.
palStatus_t pal_convertRawSignatureToDer(const unsigned char *rawSignature, size_t rawSignatureSize, unsigned char *derSignatureOut, size_t derSignatureMaxSize, size_t *derSignatureActSizeOut)
Convert ECDSA signature in RAW format to DER format.
palStatus_t pal_sha256(const unsigned char *input, size_t inLen, unsigned char output[PAL_SHA256_SIZE])
Run a SHA-256 operation on the input data.
palStatus_t pal_x509CSRFree(palx509CSRHandle_t *x509CSR)
Free the X.509 CSR context.
palStatus_t pal_CtrDRBGGenerate(palCtrDrbgCtxHandle_t ctx, unsigned char *out, size_t len)
Generate a pseudo random number using the Counter mode Deterministic Random Byte Generator (CTR-DRBG)...
palStatus_t pal_CMACFinish(palCMACHandle_t *ctx, unsigned char *output, size_t *outLen)
Finish an iterative CMAC cipher.
Definition: pal_Crypto.h:132
Definition: pal_Crypto.h:76
uintptr_t palCurveHandle_t
Definition: pal_Crypto.h:43
Definition: pal_Crypto.h:69
uintptr_t palx509CSRHandle_t
Definition: pal_Crypto.h:47
palStatus_t pal_ECDSASign(palCurveHandle_t grp, palMDType_t mdType, palECKeyHandle_t prvKey, unsigned char *dgst, uint32_t dgstLen, unsigned char *sig, size_t *sigLen)
Compute the Elliptic Curve Digital Signature Algorithm (ECDSA) signature of a previously hashed messa...
uintptr_t palCCMHandle_t
Definition: pal_Crypto.h:40
palStatus_t pal_writePrivateKeyWithHandle(const palKeyHandle_t prvKeyHandle, palECKeyHandle_t ECKeyHandle)
Write a private key from a key handle.
palMDType
Message digest algorithms supported by PAL.
Definition: pal_Crypto.h:57
palStatus_t pal_parseECPublicKeyFromDER(const unsigned char *pubDERKey, size_t keyLen, palECKeyHandle_t key)
Parse a DER-encoded public key.
enum palExtKeyUsage palExtKeyUsage_t
Extended key usage options.
palStatus_t pal_asymmetricVerify(const palECKeyHandle_t publicKeyHanlde, palMDType_t mdType, const unsigned char *hash, size_t hashSize, const unsigned char *signature, size_t signatureSize)
Verify the Elliptic Curve Digital Signature Algorithm (ECDSA) raw signature of a previously hashed me...
palStatus_t pal_setAesKey(palAesHandle_t aes, const unsigned char *key, uint32_t keybits, palAesKeyType_t keyTarget)
Set an AES key context for encryption or decryption.
palStatus_t pal_ECKeyNew(palECKeyHandle_t *key)
Allocate a key context and initialize a key pair as an invalid pair.
palStatus_t pal_x509CSRSetKeyUsage(palx509CSRHandle_t x509CSR, uint32_t keyUsage)
Set the key usage extension flags for a CSR context.
palStatus_t pal_aesCTR(palAesHandle_t aes, const unsigned char *input, unsigned char *output, size_t inLen, unsigned char iv[16])
Use AES-CTR encryption or decryption on a buffer.
palStatus_t pal_x509CertGetAttribute(palX509Handle_t x509Cert, palX509Attr_t attr, void *output, size_t outLenBytes, size_t *actualOutLenBytes)
Get an attribute from the parsed certificate.
palStatus_t pal_CCMSetKey(palCCMHandle_t ctx, const unsigned char *key, uint32_t keybits, palCipherID_t id)
Encrypt a CCM context using a set key.
palStatus_t pal_CCMDecrypt(palCCMHandle_t ctx, unsigned char *input, size_t inLen, unsigned char *iv, size_t ivLen, unsigned char *add, size_t addLen, unsigned char *tag, size_t tagLen, unsigned char *output)
Use authenticated decryption on a CCM buffer .
palExtKeyUsage
Extended key usage options.
Definition: pal_Crypto.h:125
palStatus_t pal_ECDSAVerify(palECKeyHandle_t pubKey, unsigned char *dgst, uint32_t dgstLen, unsigned char *sig, size_t sigLen, bool *verified)
Verify the Elliptic Curve Digital Signature Algorithm (ECDSA) signature of a previously hashed messag...
Definition: pal_Crypto.h:83
int32_t palStatus_t
Definition: pal_types.h:49
palStatus_t pal_freeAes(palAesHandle_t *aes)
Free an AES context.
palStatus_t pal_CCMEncrypt(palCCMHandle_t ctx, unsigned char *input, size_t inLen, unsigned char *iv, size_t ivLen, unsigned char *add, size_t addLen, unsigned char *output, unsigned char *tag, size_t tagLen)
Encrypt a CCM buffer.
Definition: pal_Crypto.h:119
palStatus_t pal_parseECPrivateKeyFromHandle(const palKeyHandle_t prvKeyHandle, palECKeyHandle_t ECKeyHandle)
Parse a private key.
uintptr_t palKeyHandle_t
Definition: pal_Crypto.h:48
Definition: pal_Crypto.h:150
Definition: pal_Crypto.h:53
Definition: pal_Crypto.h:130
uint8_t * buffer
Definition: pal_Crypto.h:158
palGroupIndex
Supported curves.
Definition: pal_Crypto.h:111
palStatus_t pal_x509Initiate(palX509Handle_t *x509Cert)
Initialize a certificate chain context.
enum palAesMode palAesMode_t
AES mode for ECB encryption and decryption.
palStatus_t pal_mdHmacSha256(const unsigned char *key, size_t keyLenInBytes, const unsigned char *input, size_t inputLenInBytes, unsigned char *output, size_t *outputLenInBytes)
Apply a one-shot Message Digest HMAC cipher.
uintptr_t palECKeyHandle_t
Definition: pal_Crypto.h:45