コード例 #1
0
ファイル: cryptoMain.c プロジェクト: SepOwnage/P-O5
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");
    }
}
コード例 #2
0
ファイル: ccm.c プロジェクト: bukka/libmcrypt
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);
}