# Crypto - Thread Stack

# Crypto - Thread Stack

This module includes cryptographic functions.

## Summary

| ### Typedefs ||
|---|---|
| `https://openthread.io/reference/group/api-crypto#group__api-crypto_1ga7f5d6794e3349c75860e2bfaf4d9ba20` | typedef `https://openthread.io/reference/struct/ot-plat-crypto-sha256-hash` Represents a SHA-256 hash. |

| ### Functions ||
|---|---|
| `https://openthread.io/reference/group/api-crypto#group__api-crypto_1ga8e2baccc7579a80b6d24692fda59410d(const https://openthread.io/reference/struct/ot-crypto-key *aKey, uint8_t aTagLength, const void *aNonce, uint8_t aNonceLength, const void *aHeader, uint32_t aHeaderLength, void *aPlainText, void *aCipherText, uint32_t aLength, bool aEncrypt, void *aTag)` | `void` Performs AES CCM computation. |
| `https://openthread.io/reference/group/api-crypto#group__api-crypto_1gac39b19c64d8d7386f07777d4bcf15de4(const https://openthread.io/reference/struct/ot-crypto-key *aKey, const uint8_t *aBuf, uint16_t aBufLength, https://openthread.io/reference/group/api-crypto#group__api-crypto_1ga7f5d6794e3349c75860e2bfaf4d9ba20 *aHash)` | `void` Performs HMAC computation. |

## Typedefs

### otCryptoSha256Hash

```
otPlatCryptoSha256Hash otCryptoSha256Hash
```
Represents a SHA-256 hash.

## Functions

### otCryptoAesCcm

```
void otCryptoAesCcm(
  const otCryptoKey *aKey,
  uint8_t aTagLength,
  const void *aNonce,
  uint8_t aNonceLength,
  const void *aHeader,
  uint32_t aHeaderLength,
  void *aPlainText,
  void *aCipherText,
  uint32_t aLength,
  bool aEncrypt,
  void *aTag
)
```
Performs AES CCM computation.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aKey` | A pointer to the key. | | `[in] aTagLength` | Length of tag in bytes. | | `[in] aNonce` | A pointer to the nonce. | | `[in] aNonceLength` | Length of nonce in bytes. | | `[in] aHeader` | A pointer to the header. | | `[in] aHeaderLength` | Length of header in bytes. | | `[in,out] aPlainText` | A pointer to the plaintext. | | `[in,out] aCipherText` | A pointer to the ciphertext. | | `[in] aLength` | Plaintext length in bytes. | | `[in] aEncrypt` | `true` on encrypt and `false` on decrypt. | | `[out] aTag` | A pointer to the tag. | |

### otCryptoHmacSha256

```
void otCryptoHmacSha256(
  const otCryptoKey *aKey,
  const uint8_t *aBuf,
  uint16_t aBufLength,
  otCryptoSha256Hash *aHash
)
```
Performs HMAC computation.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aKey` | A pointer to the key. | | `[in] aBuf` | A pointer to the input buffer. | | `[in] aBufLength` | The length of `aBuf` in bytes. | | `[out] aHash` | A pointer to a `otCryptoSha256Hash` structure to output the hash value. | |

## Resources

OpenThread API Reference topics originate from the source code, available
on [GitHub](https://github.com/openthread/openthread/tree/main/include/openthread).
For more information, or to contribute to our documentation, refer to
[Resources](https://openthread.io/resources).