Azure IoT middleware for FreeRTOS
Data Structures | Macros | Typedefs | Functions
azure_iot_jws.h File Reference

APIs working with JWS signatures to authenticate an ADU manifest. More...

#include <stdint.h>
#include "azure_iot_result.h"

Go to the source code of this file.

Data Structures

struct  AzureIoTJWS_RootKey
 Holds the values of the root key used to verify the JWS signature. More...
 

Macros

#define azureiotjwsRSA3072_SIZE   384
 
#define azureiotjwsSHA256_SIZE   32
 
#define azureiotjwsJWS_HEADER_SIZE   1400
 
#define azureiotjwsJWS_PAYLOAD_SIZE   60
 
#define azureiotjwsJWK_HEADER_SIZE   48
 
#define azureiotjwsJWK_PAYLOAD_SIZE   700
 
#define azureiotjwsSIGNATURE_SIZE   400
 
#define azureiotjwsSIGNING_KEY_E_SIZE   10
 
#define azureiotjwsSIGNING_KEY_N_SIZE   azureiotjwsRSA3072_SIZE
 
#define azureiotjwsSHA_CALCULATION_SCRATCH_SIZE   azureiotjwsRSA3072_SIZE + azureiotjwsSHA256_SIZE
 
#define azureiotjwsSCRATCH_BUFFER_SIZE
 The minimum amount of space needed to authenticate a JWS signature. More...
 

Typedefs

typedef struct AzureIoTJWS_RootKey AzureIoTJWS_RootKey_t
 Holds the values of the root key used to verify the JWS signature.
 

Functions

AzureIoTResult_t AzureIoTJWS_ManifestAuthenticate (const uint8_t *pucManifest, uint32_t ulManifestLength, uint8_t *pucJWS, uint32_t ulJWSLength, AzureIoTJWS_RootKey_t *xADURootKeys, uint32_t ulADURootKeysLength, uint8_t *pucScratchBuffer, uint32_t ulScratchBufferLength)
 Authenticate the manifest from ADU. More...
 

Detailed Description

APIs working with JWS signatures to authenticate an ADU manifest.

Macro Definition Documentation

◆ azureiotjwsJWK_HEADER_SIZE

#define azureiotjwsJWK_HEADER_SIZE   48

Size of the JWK header.

◆ azureiotjwsJWK_PAYLOAD_SIZE

#define azureiotjwsJWK_PAYLOAD_SIZE   700

Size of the JWK payload.

◆ azureiotjwsJWS_HEADER_SIZE

#define azureiotjwsJWS_HEADER_SIZE   1400

Size of the JWS header.

◆ azureiotjwsJWS_PAYLOAD_SIZE

#define azureiotjwsJWS_PAYLOAD_SIZE   60

Size of the JWS payload.

◆ azureiotjwsRSA3072_SIZE

#define azureiotjwsRSA3072_SIZE   384

Size of the RSA 3072 key.

◆ azureiotjwsSCRATCH_BUFFER_SIZE

#define azureiotjwsSCRATCH_BUFFER_SIZE
Value:
#define azureiotjwsJWK_HEADER_SIZE
Definition: azure_iot_jws.h:36
#define azureiotjwsSIGNATURE_SIZE
Definition: azure_iot_jws.h:38
#define azureiotjwsSIGNING_KEY_N_SIZE
Definition: azure_iot_jws.h:40
#define azureiotjwsSHA_CALCULATION_SCRATCH_SIZE
Definition: azure_iot_jws.h:41
#define azureiotjwsSIGNING_KEY_E_SIZE
Definition: azure_iot_jws.h:39
#define azureiotjwsJWS_HEADER_SIZE
Definition: azure_iot_jws.h:34
#define azureiotjwsJWK_PAYLOAD_SIZE
Definition: azure_iot_jws.h:37

The minimum amount of space needed to authenticate a JWS signature.

Note
azureiotjwsJWS_PAYLOAD_SIZE, one azureiotjwsSIGNATURE_SIZE, and one azureiotjwsSHA256_SIZE are excluded since they will reuse buffer space.

◆ azureiotjwsSHA256_SIZE

#define azureiotjwsSHA256_SIZE   32

Size of the SHA256 hash.

◆ azureiotjwsSHA_CALCULATION_SCRATCH_SIZE

#define azureiotjwsSHA_CALCULATION_SCRATCH_SIZE   azureiotjwsRSA3072_SIZE + azureiotjwsSHA256_SIZE

Size of the sha calculation scratch space.

◆ azureiotjwsSIGNATURE_SIZE

#define azureiotjwsSIGNATURE_SIZE   400

Size of the JWS/JWK signature.

◆ azureiotjwsSIGNING_KEY_E_SIZE

#define azureiotjwsSIGNING_KEY_E_SIZE   10

Size of the signed key exponent.

◆ azureiotjwsSIGNING_KEY_N_SIZE

#define azureiotjwsSIGNING_KEY_N_SIZE   azureiotjwsRSA3072_SIZE

Size of the signing key modulus.

Function Documentation

◆ AzureIoTJWS_ManifestAuthenticate()

AzureIoTResult_t AzureIoTJWS_ManifestAuthenticate ( const uint8_t *  pucManifest,
uint32_t  ulManifestLength,
uint8_t *  pucJWS,
uint32_t  ulJWSLength,
AzureIoTJWS_RootKey_t xADURootKeys,
uint32_t  ulADURootKeysLength,
uint8_t *  pucScratchBuffer,
uint32_t  ulScratchBufferLength 
)

Authenticate the manifest from ADU.

Parameters
[in]pucManifestThe unescaped manifest from the ADU twin property (pucUpdateManifest from AzureIoTADUUpdateRequest_t).
[in]ulManifestLengthThe length of pucManifest. (ulUpdateManifestLength from AzureIoTADUUpdateRequest_t).
[in]pucJWSThe JWS signature used to authenticate pucManifest. (pucUpdateManifestSignature from AzureIoTADUUpdateRequest_t).
[in]ulJWSLengthThe length of pucJWS. (ulUpdateManifestSignatureLength from AzureIoTADUUpdateRequest_t).
[in]xADURootKeysAn array of root keys that may be used to verify the payload.
[in]ulADURootKeysLengthThe length of the array of root keys.
[out]pucScratchBufferScratch buffer space for calculations. It should be azureiotjwsSCRATCH_BUFFER_SIZE in length.
[in]ulScratchBufferLengthThe length of pucScratchBuffer.
Returns
AzureIoTResult_t The return value of this function.
Return values
eAzureIoTSuccessif successful.
Otherwiseif failed.