elite_crack and make

This commit is contained in:
merlokk 2018-11-19 11:57:38 +02:00
commit 42b0d50686
2 changed files with 12 additions and 13 deletions

View file

@ -107,7 +107,6 @@ CORESRCS = uart_posix.c \
CMDSRCS = $(SRC_SMARTCARD) \ CMDSRCS = $(SRC_SMARTCARD) \
crapto1/crapto1.c\ crapto1/crapto1.c\
crapto1/crypto1.c\ crapto1/crypto1.c\
polarssl/des.c\
crypto/libpcrypto.c\ crypto/libpcrypto.c\
crypto/asn1utils.c\ crypto/asn1utils.c\
cliparser/argtable3.c\ cliparser/argtable3.c\

View file

@ -46,7 +46,7 @@
#include "ikeys.h" #include "ikeys.h"
#include "elite_crack.h" #include "elite_crack.h"
#include "fileutils.h" #include "fileutils.h"
#include "polarssl/des.h" #include "mbedtls/des.h"
/** /**
* @brief Permutes a key from standard NIST format to Iclass specific format * @brief Permutes a key from standard NIST format to Iclass specific format
@ -179,22 +179,22 @@ void rk(uint8_t *key, uint8_t n, uint8_t *outp_key)
return; return;
} }
static des_context ctx_enc = {DES_ENCRYPT,{0}}; static mbedtls_des_context ctx_enc = {0};
static des_context ctx_dec = {DES_DECRYPT,{0}}; static mbedtls_des_context ctx_dec = {0};
void desdecrypt_iclass(uint8_t *iclass_key, uint8_t *input, uint8_t *output) void desdecrypt_iclass(uint8_t *iclass_key, uint8_t *input, uint8_t *output)
{ {
uint8_t key_std_format[8] = {0}; uint8_t key_std_format[8] = {0};
permutekey_rev(iclass_key, key_std_format); permutekey_rev(iclass_key, key_std_format);
des_setkey_dec( &ctx_dec, key_std_format); mbedtls_des_setkey_dec( &ctx_dec, key_std_format);
des_crypt_ecb(&ctx_dec,input,output); mbedtls_des_crypt_ecb(&ctx_dec,input,output);
} }
void desencrypt_iclass(uint8_t *iclass_key, uint8_t *input, uint8_t *output) void desencrypt_iclass(uint8_t *iclass_key, uint8_t *input, uint8_t *output)
{ {
uint8_t key_std_format[8] = {0}; uint8_t key_std_format[8] = {0};
permutekey_rev(iclass_key, key_std_format); permutekey_rev(iclass_key, key_std_format);
des_setkey_enc( &ctx_enc, key_std_format); mbedtls_des_setkey_enc( &ctx_enc, key_std_format);
des_crypt_ecb(&ctx_enc,input,output); mbedtls_des_crypt_ecb(&ctx_enc,input,output);
} }
/** /**
@ -449,7 +449,7 @@ int bruteforceItem(dumpdata item, uint16_t keytable[])
*/ */
int calculateMasterKey(uint8_t first16bytes[], uint64_t master_key[] ) int calculateMasterKey(uint8_t first16bytes[], uint64_t master_key[] )
{ {
des_context ctx_e = {DES_ENCRYPT,{0}}; mbedtls_des_context ctx_e = {0};
uint8_t z_0[8] = {0}; uint8_t z_0[8] = {0};
uint8_t y_0[8] = {0}; uint8_t y_0[8] = {0};
@ -468,8 +468,8 @@ int calculateMasterKey(uint8_t first16bytes[], uint64_t master_key[] )
permutekey_rev(z_0, z_0_rev); permutekey_rev(z_0, z_0_rev);
// ~K_cus = DESenc(z[0], y[0]) // ~K_cus = DESenc(z[0], y[0])
des_setkey_enc( &ctx_e, z_0_rev ); mbedtls_des_setkey_enc( &ctx_e, z_0_rev );
des_crypt_ecb(&ctx_e, y_0, key64_negated); mbedtls_des_crypt_ecb(&ctx_e, y_0, key64_negated);
int i; int i;
for(i = 0; i < 8 ; i++) for(i = 0; i < 8 ; i++)
@ -482,8 +482,8 @@ int calculateMasterKey(uint8_t first16bytes[], uint64_t master_key[] )
uint8_t key64_stdformat[8] = {0}; uint8_t key64_stdformat[8] = {0};
permutekey_rev(key64, key64_stdformat); permutekey_rev(key64, key64_stdformat);
des_setkey_enc( &ctx_e, key64_stdformat ); mbedtls_des_setkey_enc( &ctx_e, key64_stdformat );
des_crypt_ecb(&ctx_e, key64_negated, result); mbedtls_des_crypt_ecb(&ctx_e, key64_negated, result);
prnlog("\nHigh security custom key (Kcus):"); prnlog("\nHigh security custom key (Kcus):");
printvar("Std format ", key64_stdformat,8); printvar("Std format ", key64_stdformat,8);
printvar("Iclass format", key64,8); printvar("Iclass format", key64,8);