void readData(ENC_ctx *ENC_ctx_receiver,const message_ctx *ciphermessage, unsigned char *out, unsigned int *output_size) { CCM_decrypt(out, output_size, ENC_ctx_receiver,ciphermessage); if (PRINT_inputs_outputs && *output_size != 0){ printf("\n-->Decrypt: %s\n", out); print_hex_memory(out, *output_size); printf("\n"); } }
ret_type CCM_mode( const unsigned char key[], const unsigned long key_len, /* the key value to be used */ const unsigned char nonce[], /* the nonce value */ const unsigned char auth[], const unsigned long ad_len, /* the additional authenticated data */ unsigned char msg[], const mlen_type msg_len, /* the message data */ const unsigned long auth_field_len, /* the authentication field length */ const int ed_flag) /* 0 = encrypt, 1 = decrypt */ { CCM_ctx ctx[1]; ret_type ec; ec = CCM_init(key, key_len, nonce, auth, ad_len, msg_len, auth_field_len, ctx); return ec != CCM_ok ? ec : ed_flag ? CCM_decrypt(msg, msg, msg_len + auth_field_len, ctx) : CCM_encrypt(msg, msg, msg_len, ctx); }