]>
git.zerfleddert.de Git - proxmark3-svn/blob - common/polarssl/libpcrypto.c
032c3a18bcf49bb6fda4b996b329de4692ea568c
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2018 Merlok
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
9 //-----------------------------------------------------------------------------
11 #include "polarssl/libpcrypto.h"
12 #include <polarssl/aes.h>
14 int aes_encode(uint8_t *iv
, uint8_t *key
, uint8_t *input
, uint8_t *output
, int length
){
15 uint8_t iiv
[16] = {0};
21 if (aes_setkey_enc(&aes
, key
, 128))
23 if (aes_crypt_cbc(&aes
, AES_ENCRYPT
, length
, iiv
, input
, output
))
30 int aes_decode(uint8_t *iv
, uint8_t *key
, uint8_t *input
, uint8_t *output
, int length
){
31 uint8_t iiv
[16] = {0};
37 if (aes_setkey_dec(&aes
, key
, 128))
39 if (aes_crypt_cbc(&aes
, AES_DECRYPT
, length
, iiv
, input
, output
))