mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-13 16:53:00 -07:00
Mfp commands (#698)
* add write perso from https://github.com/Proxmark/proxmark3/blob/master/client/scripts/mifarePlus.lua * commit perso from https://github.com/Proxmark/proxmark3/blob/master/client/scripts/mifarePlus.lua#L184 * added errors https://github.com/Proxmark/proxmark3/blob/master/client/scripts/mifarePlus.lua#L91 * fix bug in CLIParamHexToBuf * added init card command * auth4 refactoring * add changelog
This commit is contained in:
parent
3685f89cbd
commit
ae3340a0fb
11 changed files with 529 additions and 115 deletions
44
common/polarssl/libpcrypto.c
Normal file
44
common/polarssl/libpcrypto.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2018 Merlok
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// crypto commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "polarssl/libpcrypto.h"
|
||||
#include <polarssl/aes.h>
|
||||
|
||||
int aes_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, 16);
|
||||
|
||||
aes_context aes;
|
||||
aes_init(&aes);
|
||||
if (aes_setkey_enc(&aes, key, 128))
|
||||
return 1;
|
||||
if (aes_crypt_cbc(&aes, AES_ENCRYPT, length, iiv, input, output))
|
||||
return 2;
|
||||
aes_free(&aes);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int aes_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);
|
||||
|
||||
aes_context aes;
|
||||
aes_init(&aes);
|
||||
if (aes_setkey_dec(&aes, key, 128))
|
||||
return 1;
|
||||
if (aes_crypt_cbc(&aes, AES_DECRYPT, length, iiv, input, output))
|
||||
return 2;
|
||||
aes_free(&aes);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue