mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
add aes256
This commit is contained in:
parent
58690ed24e
commit
0dc80263e8
2 changed files with 43 additions and 0 deletions
|
@ -163,6 +163,45 @@ int aes_decode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int l
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NIST Special Publication 800-38A — Recommendation for block cipher modes of operation: methods and techniques, 2001.
|
||||||
|
int aes256_encode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length) {
|
||||||
|
uint8_t iiv[16] = {0};
|
||||||
|
if (iv) {
|
||||||
|
memcpy(iiv, iv, sizeof(iiv));
|
||||||
|
}
|
||||||
|
|
||||||
|
mbedtls_aes_context aes;
|
||||||
|
mbedtls_aes_init(&aes);
|
||||||
|
if (mbedtls_aes_setkey_enc(&aes, key, 256)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_ENCRYPT, length, iiv, input, output)) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
mbedtls_aes_free(&aes);
|
||||||
|
return PM3_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int aes256_decode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length) {
|
||||||
|
uint8_t iiv[16] = {0};
|
||||||
|
if (iv) {
|
||||||
|
memcpy(iiv, iv, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
mbedtls_aes_context aes;
|
||||||
|
mbedtls_aes_init(&aes);
|
||||||
|
if (mbedtls_aes_setkey_dec(&aes, key, 256)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_DECRYPT, length, iiv, input, output)) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
mbedtls_aes_free(&aes);
|
||||||
|
return PM3_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// NIST Special Publication 800-38B — Recommendation for block cipher modes of operation: The CMAC mode for authentication.
|
// NIST Special Publication 800-38B — Recommendation for block cipher modes of operation: The CMAC mode for authentication.
|
||||||
// https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/AES_CMAC.pdf
|
// https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/AES_CMAC.pdf
|
||||||
int aes_cmac(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *mac, int length) {
|
int aes_cmac(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *mac, int length) {
|
||||||
|
|
|
@ -38,6 +38,10 @@ void des3_decrypt(void *out, const void *in, const void *key, uint8_t keycount);
|
||||||
|
|
||||||
int aes_encode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length);
|
int aes_encode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length);
|
||||||
int aes_decode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length);
|
int aes_decode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length);
|
||||||
|
|
||||||
|
int aes256_encode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length);
|
||||||
|
int aes256_decode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length);
|
||||||
|
|
||||||
int aes_cmac(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *mac, int length);
|
int aes_cmac(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *mac, int length);
|
||||||
int aes_cmac8(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *mac, int length);
|
int aes_cmac8(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *mac, int length);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue