Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Why does ECB encryption return 32 octets with a block size of 16? #137

Open
ghost opened this issue Jan 2, 2018 · 3 comments
Open

Why does ECB encryption return 32 octets with a block size of 16? #137

ghost opened this issue Jan 2, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 2, 2018

Hi, I'm trying to use the currently undocumented ECB functions. I'm puzzled as to why the encrypt function returns 32 octets when it looks like a block size of 16 is specified as the default. Here's my test:

// ECB test
var asmcrypto = require('./asmcrypto.all');
var utils = require('./utils.js');

// AEC-ECB(000000000012345677E4D611358EAF17,8b84eedec100067d670971dd2aa700cf)
var hex_data    = "000000000012345677E4D611358EAF17";
var hex_key     = "8b84eedec100067d670971dd2aa700cf";
var hex_padding = "";

console.log("encrypt("+hex_data+","+hex_key+")");
var ecb_encrypted = asmcrypto.AES_ECB.encrypt( utils.hexToU8A(hex_data), utils.hexToU8A(hex_key), utils.hexToU8A(hex_padding));
console.log(asmcrypto.bytes_to_hex(ecb_encrypted));

and this produces the following output:

encrypt(000000000012345677E4D611358EAF17,8b84eedec100067d670971dd2aa700cf)
b2021754866e87226cf5b7f4232d216a7e1ba4becd78a1741240f6e18e623a43

The first 16 octets are my expected result:

b2021754866e87226cf5b7f4232d216a

What are the 16 which follow?

Thanks

@alippai
Copy link
Member

alippai commented Jun 3, 2018

Can you check version 2.0, please? The API may be changed.

@ghost
Copy link
Author

ghost commented Jun 4, 2018

It looks like the fix has been regressed. I just ran my test code against the same asmcrypto code I was using last year and compared with the latest from head, cloned a few minutes ago.

From HEAD:

encrypt(000000000012345677E4D611358EAF17,8b84eedec100067d670971dd2aa700cf)
b2021754866e87226cf5b7f4232d216a7e1ba4becd78a1741240f6e18e623a43
------
decrypt(b2021754866e87226cf5b7f4232d216a7e1ba4becd78a1741240f6e18e623a43,8b84eedec100067d670971dd2aa700cf)
000000000012345677e4d611358eaf17

Last year's code

encrypt(000000000012345677E4D611358EAF17,8b84eedec100067d670971dd2aa700cf)
b2021754866e87226cf5b7f4232d216a
------
decrypt(b2021754866e87226cf5b7f4232d216a,8b84eedec100067d670971dd2aa700cf)
000000000012345677e4d611358eaf17

@alippai
Copy link
Member

alippai commented Jun 4, 2018

I see the error cause now, we will fix it shortly and add these test cases. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant