This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is it Possible to Use Aead CCM (on a NRF 52840 with CC310) to verify a message without an encrypted Message? (Just Adata)

Hi, 

i use the Aead-Lib for CCM on the NRF52840. What is the best way to Check an Mac from a Message wich only has Adata (no acctual encryptet message)?  

If i try to use a decrypt i get the error code for: "An internal error occurred when calling this function"

Parents
  • the code i uses looks like: 

    uint8_t key[16] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
    uint8_t nonce[13] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x00, 0x00};
    uint8_t mac[4] = {0xFF,0xFF, 0xFF, 0xFF}; // DEMO
    uint8_t ret_buffer[20];
    uint8_t auth[4] = {0xAA, 0xBB,0xCC,0xDD};
    uint8_t adata[9]  = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
    ret_code_t ret;
    
    
    nrf_crypto_aead_info_t const * p_ccm_info = &g_nrf_crypto_aes_ccm_128_info;
    
    ret = nrf_crypto_aead_init(&ccm_ctx, p_ccm_info, key);
    APP_ERROR_CHECK(ret);
    
    ret = nrf_crypto_aead_crypt(&ccm_ctx, NRF_CRYPTO_DECRYPT, nonce, sizeof(nonce), adata, sizeof(adata), auth,0, ret_buffer, mac, sizeof(mac));
    
    printf(nrf_crypto_error_string_get(ret));

Reply
  • the code i uses looks like: 

    uint8_t key[16] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
    uint8_t nonce[13] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x00, 0x00};
    uint8_t mac[4] = {0xFF,0xFF, 0xFF, 0xFF}; // DEMO
    uint8_t ret_buffer[20];
    uint8_t auth[4] = {0xAA, 0xBB,0xCC,0xDD};
    uint8_t adata[9]  = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
    ret_code_t ret;
    
    
    nrf_crypto_aead_info_t const * p_ccm_info = &g_nrf_crypto_aes_ccm_128_info;
    
    ret = nrf_crypto_aead_init(&ccm_ctx, p_ccm_info, key);
    APP_ERROR_CHECK(ret);
    
    ret = nrf_crypto_aead_crypt(&ccm_ctx, NRF_CRYPTO_DECRYPT, nonce, sizeof(nonce), adata, sizeof(adata), auth,0, ret_buffer, mac, sizeof(mac));
    
    printf(nrf_crypto_error_string_get(ret));

Children
Related