minors stuff, added some blowfish decrypt
This commit is contained in:
1 parent
2c06054881
commit
2c61530cba
6 files changed
+37
-8
No files matched your search
@@ -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 */
|
||||
Reference in new issue
Block a user