cmac

AES-CMAC module for Node.js?

ε祈祈猫儿з 提交于 2021-02-11 17:23:46
问题 Is there a Node.js module that handles AES-CMAC (RFC 4493)? I've been searching around NPM, Google, and the like, but haven't found one. Somebody within my company built one that wraps Crypto++ as a C++ addon for Node.js, but unfortunately it doesn't build on Windows (depends on make ). Just looking for possible alternatives. This is similar to this other question, but I'm hoping for a Node.js specific implementation instead of a plain JavaScript one. Ideally something that makes use of Node

How to use Bouncycastle's CMac

非 Y 不嫁゛ 提交于 2019-12-22 08:35:00
问题 I'm trying to use BouncyCastle's CMac implementation but apparently I'm doing it wrong. At least the following unit test (based on RFC 5297 test vectors) fails: @Test public void testCMacOfZeros() { byte[] key = {(byte) 0xff, (byte) 0xfe, (byte) 0xfd, (byte) 0xfc, // (byte) 0xfb, (byte) 0xfa, (byte) 0xf9, (byte) 0xf8, // (byte) 0xf7, (byte) 0xf6, (byte) 0xf5, (byte) 0xf4, // (byte) 0xf3, (byte) 0xf2, (byte) 0xf1, (byte) 0xf0, // (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, // (byte)

CMAC Key generation with OpenSSL EVP_DigestSign* fails

浪尽此生 提交于 2019-12-22 05:08:14
问题 I am trying to generate key for computing the CMAC with OpenSSL. However, these seem to fail with the error message copied below. Can someone point out where the problem is? Has anybody done CMAC with EVP_DigestSign* calls? Here is part of the code which has been constructed from the example at https://wiki.openssl.org/index.php/EVP_Key_and_Parameter_Generation : BIO *out = NULL; out = BIO_new(BIO_s_file()); if (out == NULL) return -1; BIO_set_fp(out, stdout, BIO_NOCLOSE); EVP_MD_CTX* rctx =

How can I generate CMAC-AES in javascript

ⅰ亾dé卋堺 提交于 2019-12-07 11:32:06
问题 I am attempting to use the Stanford Javascript Crypto Library to generate an CMAC-AES token for an OAuth 2.0 assertion, but I'm far from being an expert with cryptography. Can someone give an example using sjcl or any open-license js library out there? I'm not even sure it's possible using sjcl's existing functions. I tried using an options object like I saw in this question, but I don't understand the modes or other options, and I couldn't find any documentation on this. I figure the salt

AES CMAC Calculation C#

ⅰ亾dé卋堺 提交于 2019-12-06 08:47:38
问题 I know MAC is 4 first byte of last block encryption, and found this CMAC explanation here but it's kinda hard to understand. And maybe there are already some CMAC AES questions but I'm sorry I can't understand it well. Anyone can explain how to calculate CMAC? and if necessary with some example code in C#. Thanks 回答1: First you need to derive two subkeys from your AES key. The algorithm is described well in RFC4493, but I will include some code samples here for reference. For this, you will

How to use Bouncycastle's CMac

依然范特西╮ 提交于 2019-12-05 16:10:13
I'm trying to use BouncyCastle's CMac implementation but apparently I'm doing it wrong. At least the following unit test (based on RFC 5297 test vectors) fails: @Test public void testCMacOfZeros() { byte[] key = {(byte) 0xff, (byte) 0xfe, (byte) 0xfd, (byte) 0xfc, // (byte) 0xfb, (byte) 0xfa, (byte) 0xf9, (byte) 0xf8, // (byte) 0xf7, (byte) 0xf6, (byte) 0xf5, (byte) 0xf4, // (byte) 0xf3, (byte) 0xf2, (byte) 0xf1, (byte) 0xf0, // (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, // (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, // (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, //

How can I generate CMAC-AES in javascript

老子叫甜甜 提交于 2019-12-05 14:53:42
I am attempting to use the Stanford Javascript Crypto Library to generate an CMAC-AES token for an OAuth 2.0 assertion, but I'm far from being an expert with cryptography. Can someone give an example using sjcl or any open-license js library out there? I'm not even sure it's possible using sjcl's existing functions. I tried using an options object like I saw in this question , but I don't understand the modes or other options, and I couldn't find any documentation on this. I figure the salt and iv (to be a reproduceable MAC) would have to be static, but I don't know what values they should be.

CMAC Key generation with OpenSSL EVP_DigestSign* fails

天涯浪子 提交于 2019-12-05 05:51:11
I am trying to generate key for computing the CMAC with OpenSSL. However, these seem to fail with the error message copied below. Can someone point out where the problem is? Has anybody done CMAC with EVP_DigestSign* calls? Here is part of the code which has been constructed from the example at https://wiki.openssl.org/index.php/EVP_Key_and_Parameter_Generation : BIO *out = NULL; out = BIO_new(BIO_s_file()); if (out == NULL) return -1; BIO_set_fp(out, stdout, BIO_NOCLOSE); EVP_MD_CTX* rctx = NULL; EVP_PKEY *pkey = NULL; EVP_PKEY_CTX *kctx = NULL; rctx = EVP_MD_CTX_create(); if(rctx == NULL) {

AES CMAC Calculation C#

坚强是说给别人听的谎言 提交于 2019-12-04 13:39:25
I know MAC is 4 first byte of last block encryption, and found this CMAC explanation here but it's kinda hard to understand. And maybe there are already some CMAC AES questions but I'm sorry I can't understand it well. Anyone can explain how to calculate CMAC? and if necessary with some example code in C#. Thanks First you need to derive two subkeys from your AES key. The algorithm is described well in RFC4493 , but I will include some code samples here for reference. For this, you will need the AESEncrypt function, which you can write using dotNet AesCryptoServiceProvider : byte[] AESEncrypt

How to calculate AES CMAC using OpenSSL's CMAC_xxx functions?

怎甘沉沦 提交于 2019-11-30 07:39:39
问题 Is there any way to compute AES CMAC with OpenSSL / libcrypto ? Preferably in a way that takes advantage of AES-NI (or any other hardware acceleration). See also CMAC Key generation with OpenSSL EVP_DigestSign* fails 回答1: As stated in my blog post you can use the CMAC_CTX_new , CMAC_Init , CMAC_Update and CMAC_Final from lib crypto to calculate AES-128-CBC CMAC. Here is an example: #include <stdio.h> #include <openssl/cmac.h> void printBytes(unsigned char *buf, size_t len) { for(int i=0; i