mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-30 11:39:14 -07:00
minors stuff, added some blowfish decrypt
This commit is contained in:
parent
2c06054881
commit
2c61530cba
6 changed files with 37 additions and 8 deletions
|
@ -33,6 +33,7 @@
|
|||
#include <mbedtls/ctr_drbg.h>
|
||||
#include <mbedtls/entropy.h>
|
||||
#include <mbedtls/error.h>
|
||||
#include <mbedtls/blowfish.h>
|
||||
#include "util.h"
|
||||
#include "ui.h"
|
||||
|
||||
|
@ -614,3 +615,20 @@ size_t FindISO9797M2PaddingDataLen(const uint8_t *data, size_t datalen) {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int blowfish_decrypt(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length) {
|
||||
uint8_t iiv[16] = {0x00 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
if (iv)
|
||||
memcpy(iiv, iv, 16);
|
||||
|
||||
mbedtls_blowfish_context blow;
|
||||
mbedtls_blowfish_init(&blow);
|
||||
if (mbedtls_blowfish_setkey(&blow, key, 64))
|
||||
return 1;
|
||||
if (mbedtls_blowfish_crypt_cbc(&blow, MBEDTLS_BLOWFISH_DECRYPT, length, iiv, input, output))
|
||||
return 2;
|
||||
mbedtls_blowfish_free(&blow);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -61,5 +61,7 @@ void bin_xor(uint8_t *d1, const uint8_t *d2, size_t len);
|
|||
void AddISO9797M2Padding(uint8_t *ddata, size_t *ddatalen, uint8_t *sdata, size_t sdatalen, size_t blocklen);
|
||||
size_t FindISO9797M2PaddingDataLen(const uint8_t *data, size_t datalen);
|
||||
|
||||
// BLOWFISH
|
||||
int blowfish_decrypt(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length);
|
||||
|
||||
#endif /* libpcrypto.h */
|
||||
|
|
|
@ -23,19 +23,20 @@
|
|||
#endif
|
||||
|
||||
#include "tlv.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define TLV_TAG_CLASS_MASK 0xc0
|
||||
|
||||
#define TLV_TAG_CLASS_MASK 0xC0
|
||||
#define TLV_TAG_COMPLEX 0x20
|
||||
#define TLV_TAG_VALUE_MASK 0x1f
|
||||
#define TLV_TAG_VALUE_CONT 0x1f
|
||||
#define TLV_TAG_VALUE_MASK 0x1F
|
||||
#define TLV_TAG_VALUE_CONT 0x1F
|
||||
#define TLV_TAG_INVALID 0
|
||||
|
||||
#define TLV_LEN_LONG 0x80
|
||||
#define TLV_LEN_MASK 0x7f
|
||||
#define TLV_LEN_MASK 0x7F
|
||||
#define TLV_LEN_INVALID (~0)
|
||||
|
||||
// http://radek.io/2012/11/10/magical-container_of-macro/
|
||||
|
|
|
@ -83,7 +83,7 @@ DumpFileType_t getfiletype(const char *filename) {
|
|||
} else if (str_endswith(s, "json")) {
|
||||
o = JSON;
|
||||
} else if (str_endswith(s, "dic")) {
|
||||
o = DICTIONARY;
|
||||
o = DICTIONARY;
|
||||
} else {
|
||||
// mfd, trc, trace is binary
|
||||
o = BIN;
|
||||
|
@ -1916,4 +1916,11 @@ int pm3_load_dump(const char *fn, void **pdump, size_t *dumplen, size_t maxdumpl
|
|||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
int pm3_save_dump(const char *fn, uint8_t *d, size_t n, JSONFileType jsft, size_t blocksize) {
|
||||
saveFile(fn, ".bin", d, n);
|
||||
saveFileEML(fn, d, n, blocksize);
|
||||
saveFileJSON(fn, jsft, d, n, NULL);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -272,4 +272,5 @@ DumpFileType_t getfiletype(const char *filename);
|
|||
*/
|
||||
int pm3_load_dump(const char *fn, void **pdump, size_t *dumplen, size_t maxdumplen);
|
||||
|
||||
int pm3_save_dump(const char *fn, uint8_t *d, size_t n, JSONFileType jsft, size_t blocksize);
|
||||
#endif // FILEUTILS_H
|
||||
|
|
|
@ -403,4 +403,4 @@ bool HasMADKey(uint8_t *d) {
|
|||
return false;
|
||||
|
||||
return (memcmp(d + (3 * MFBLOCK_SIZE), g_mifare_mad_key, sizeof(g_mifare_mad_key)) == 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue