Microchip® Advanced Software Framework

winc3400/wifi_drv/driver/include/m2m_crypto.h File Reference

WINC3400 Crypto API.

Copyright (c) 2016-2019 Microchip Technology Inc. and its subsidiaries.

#include "common/include/nm_common.h"
#include "driver/include/m2m_types.h"

Data Structures

struct  sha256ctxt
 

Macros

#define M2M_SHA256_CONTEXT_BUFF_LEN   128
 
#define M2M_SHA256_DIGEST_LEN   32
 

Typedefs

typedef struct sha256ctxt tstrM2mSha256Ctxt
 

Enumerations

enum  tenuRsaSignStatus {
  M2M_RSA_SIGN_OK,
  M2M_RSA_SIGN_FAIL,
  M2M_RSA_SIGN_OK,
  M2M_RSA_SIGN_FAIL
}
 RSA Signature status: pass or fail. More...
 

Functions

sint8 m2m_rsa_sign_gen (uint8 *pu8N, uint16 u16NSize, uint8 *pu8d, uint16 u16dSize, uint8 *pu8SignedMsgHash, uint16 u16HashLength, uint8 *pu8RsaSignature)
 RSA Signature Generation. More...
 
sint8 m2m_rsa_sign_verify (uint8 *pu8N, uint16 u16NSize, uint8 *pu8E, uint16 u16ESize, uint8 *pu8SignedMsgHash, uint16 u16HashLength, uint8 *pu8RsaSignature)
 RSA Signature Verification. More...
 
sint8 m2m_sha256_hash_finish (tstrM2mSha256Ctxt *psha256Ctxt, uint8 *pu8Sha256Digest)
 SHA256 hash finalization. More...
 
sint8 m2m_sha256_hash_init (tstrM2mSha256Ctxt *psha256Ctxt)
 SHA256 hash initialization. More...
 
sint8 m2m_sha256_hash_update (tstrM2mSha256Ctxt *psha256Ctxt, uint8 *pu8Data, uint16 u16DataLength)
 SHA256 hash update. More...
 

#define M2M_SHA256_CONTEXT_BUFF_LEN   128
#define M2M_SHA256_DIGEST_LEN   32

typedef struct sha256ctxt tstrM2mSha256Ctxt

RSA Signature status: pass or fail.

See Also
m2m_crypto_rsa_sign_gen
Enumerator
M2M_RSA_SIGN_OK 
M2M_RSA_SIGN_FAIL 
M2M_RSA_SIGN_OK 
M2M_RSA_SIGN_FAIL 

sint8 m2m_rsa_sign_gen ( uint8 pu8N,
uint16  u16NSize,
uint8 pu8d,
uint16  u16dSize,
uint8 pu8SignedMsgHash,
uint16  u16HashLength,
uint8 pu8RsaSignature 
)

RSA Signature Generation.

The function shall request the RSA Signature generation from the WINC Firmware for the given message. The signed message shall be
compressed to the corresponding hash algorithm before calling this function.
The hash type is identified by the given hash length. For example, if the hash length is 32 bytes, then it is SHA256.
Parameters
[in]pu8NRSA Key modulus n.
[in]u16NSizeSize of the RSA modulus n in bytes.
[in]pu8dRSA private exponent.
[in]u16dSizeSize of the RSA private exponent in bytes.
[in]pu8SignedMsgHashThe hash digest of the signed message.
[in]u16HashLengthThe length of the hash digest.
[out]pu8RsaSignaturePointer to a user buffer allocated by teh caller shall hold the generated signature.
The function shall request the RSA Signature generation from the WINC Firmware for the given message. The signed message shall be 
compressed to the corresponding hash algorithm before calling this function.
The hash type is identified by the given hash length. For example, if the hash length is 32 bytes, then it is SHA256.
Parameters
[in]pu8NRSA Key modulus n.
[in]u16NSizeSize of the RSA modulus n in bytes.
[in]pu8dRSA private exponent.
[in]u16dSizeSize of the RSA private exponent in bytes.
[in]pu8SignedMsgHashThe hash digest of the signed message.
[in]u16HashLengthThe length of the hash digest.
[out]pu8RsaSignaturePointer to a user buffer allocated by the caller shall hold the generated signature.
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
sint8 m2m_rsa_sign_verify ( uint8 pu8N,
uint16  u16NSize,
uint8 pu8E,
uint16  u16ESize,
uint8 pu8SignedMsgHash,
uint16  u16HashLength,
uint8 pu8RsaSignature 
)

RSA Signature Verification.

The function shall request the RSA Signature verification from the WINC Firmware for the given message. The signed message shall be
compressed to the corresponding hash algorithm before calling this function.
The hash type is identified by the given hash length. For example, if the hash length is 32 bytes, then it is SHA256.
Parameters
[in]pu8NRSA Key modulus n.
[in]u16NSizeSize of the RSA modulus n in bytes.
[in]pu8ERSA public exponent.
[in]u16ESizeSize of the RSA public exponent in bytes.
[in]pu8SignedMsgHashThe hash digest of the signed message.
[in]u16HashLengthThe length of the hash digest.
[out]pu8RsaSignatureSignature value to be verified.
The function shall request the RSA Signature verification from the WINC Firmware for the given message. The signed message shall be 
compressed to the corresponding hash algorithm before calling this function.
The hash type is identified by the given hash length. For example, if the hash length is 32 bytes, then it is SHA256.
Parameters
[in]pu8NRSA Key modulus n.
[in]u16NSizeSize of the RSA modulus n in bytes.
[in]pu8ERSA public exponent.
[in]u16ESizeSize of the RSA public exponent in bytes.
[in]pu8SignedMsgHashThe hash digest of the signed message.
[in]u16HashLengthThe length of the hash digest.
[out]pu8RsaSignatureSignature value to be verified.
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
sint8 m2m_sha256_hash_finish ( tstrM2mSha256Ctxt psha256Ctxt,
uint8 pu8Sha256Digest 
)

SHA256 hash finalization.

Parameters
[in]psha256CtxtPointer to a sha256 context allocated by the caller.
[in]pu8Sha256DigestBuffer allocated by the caller which will hold the resultant SHA256 Digest. It must be allocated no less than M2M_SHA256_DIGEST_LEN.
[in]psha256CtxtPointer to a sha256 context allocated by the caller.
[in]pu8Sha256DigestBuffer allocated by the caller which will hold the resultant SHA256 Digest. It must be allocated no less than M2M_SHA256_DIGEST_LEN.
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
sint8 m2m_sha256_hash_init ( tstrM2mSha256Ctxt psha256Ctxt)

SHA256 hash initialization.

Parameters
[in]psha256CtxtPointer to a sha256 context allocated by the caller.
[in]psha256CtxtPointer to a sha256 context allocated by the caller.
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
sint8 m2m_sha256_hash_update ( tstrM2mSha256Ctxt psha256Ctxt,
uint8 pu8Data,
uint16  u16DataLength 
)

SHA256 hash update.

Parameters
[in]psha256CtxtPointer to the sha256 context.
[in]pu8DataBuffer holding the data submitted to the hash.
[in]u16DataLengthSize of the data buffer in bytes.
[in]psha256CtxtPointer to the sha256 context.
[in]pu8DataBuffer holding the data submitted to the hash.
[in]u16DataLengthSize of the data buffer in bytes.
Precondition
SHA256 module should be initialized first through m2m_crypto_sha256_hash_init function.
See Also
m2m_crypto_sha256_hash_init
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.