mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 06:13:51 -07:00
add some consts and kvv
This commit is contained in:
parent
05c8f313dd
commit
f17cbfe412
3 changed files with 34 additions and 12 deletions
|
@ -17,9 +17,26 @@
|
||||||
#include "cmdhf14a.h"
|
#include "cmdhf14a.h"
|
||||||
#include "emv/emvcore.h"
|
#include "emv/emvcore.h"
|
||||||
#include "emv/emvjson.h"
|
#include "emv/emvjson.h"
|
||||||
|
#include "crypto/libpcrypto.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
uint8_t AESData0[CIPURSE_AES_KEY_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
|
static void CipurseCGenerateK0AndGetCp(CipurseContext *ctx) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CipurseCGenerateCT(uint8_t *RT, uint8_t *CT) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CipurseCGetKVV(uint8_t *key, uint8_t *kvv) {
|
||||||
|
uint8_t res[16] = {0};
|
||||||
|
aes_encode(NULL, key, AESData0, res, CIPURSE_AES_KEY_LENGTH);
|
||||||
|
memcpy(kvv, res, CIPURSE_KVV_LENGTH);
|
||||||
|
}
|
||||||
|
|
||||||
void CipurseClearContext(CipurseContext *ctx) {
|
void CipurseClearContext(CipurseContext *ctx) {
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -54,12 +71,7 @@ void CipurseAuthenticateHost(CipurseContext *ctx) {
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* RT = Random.nextBytes(16)
|
CipurseSetRandomHost(ctx);
|
||||||
rT = Random.nextBytes(6)
|
CipurseCGenerateK0AndGetCp(ctx);
|
||||||
|
CipurseCGenerateCT(ctx->RT, ctx->CT);
|
||||||
val cP = generateK0AndGetCp(key, RP, rP, RT, rT) ?: return Pair(null, null)
|
|
||||||
|
|
||||||
return Pair(cP + RT + rT, generateCT(RT))*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#define CIPURSE_KVV_LENGTH 4
|
||||||
|
#define CIPURSE_AES_KEY_LENGTH 16
|
||||||
|
#define CIPURSE_SECURITY_PARAM_N 6
|
||||||
|
#define OSPT_MAC_LENGTH 8
|
||||||
|
|
||||||
#define member_size(type, member) sizeof(((type *)0)->member)
|
#define member_size(type, member) sizeof(((type *)0)->member)
|
||||||
|
|
||||||
enum CipurseChannelSecurityLevel {
|
enum CipurseChannelSecurityLevel {
|
||||||
|
@ -24,7 +29,7 @@ enum CipurseChannelSecurityLevel {
|
||||||
|
|
||||||
typedef struct CipurseContextS {
|
typedef struct CipurseContextS {
|
||||||
uint8_t keyId;
|
uint8_t keyId;
|
||||||
uint8_t key[16];
|
uint8_t key[CIPURSE_AES_KEY_LENGTH];
|
||||||
|
|
||||||
uint8_t RP[16];
|
uint8_t RP[16];
|
||||||
uint8_t rP[6];
|
uint8_t rP[6];
|
||||||
|
@ -33,9 +38,10 @@ typedef struct CipurseContextS {
|
||||||
|
|
||||||
uint8_t frameKey0[16];
|
uint8_t frameKey0[16];
|
||||||
uint8_t cP[16];
|
uint8_t cP[16];
|
||||||
|
uint8_t CT[16];
|
||||||
|
|
||||||
uint8_t frameKey[16];
|
uint8_t frameKey[CIPURSE_AES_KEY_LENGTH];
|
||||||
uint8_t frameKeyNext[16];
|
uint8_t frameKeyNext[CIPURSE_AES_KEY_LENGTH];
|
||||||
} CipurseContext;
|
} CipurseContext;
|
||||||
|
|
||||||
void CipurseClearContext(CipurseContext *ctx);
|
void CipurseClearContext(CipurseContext *ctx);
|
||||||
|
@ -46,6 +52,6 @@ void CipurseSetRandomHost(CipurseContext *ctx);
|
||||||
void CipurseAuthenticateHost(CipurseContext *ctx);
|
void CipurseAuthenticateHost(CipurseContext *ctx);
|
||||||
|
|
||||||
|
|
||||||
|
void CipurseCGetKVV(uint8_t *key, uint8_t *kvv);
|
||||||
|
|
||||||
#endif /* __CIPURSECRYPTO_H__ */
|
#endif /* __CIPURSECRYPTO_H__ */
|
||||||
|
|
|
@ -98,6 +98,10 @@ static int CmdHFCipurseAuth(const char *Cmd) {
|
||||||
uint8_t key[] = {0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73};
|
uint8_t key[] = {0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73};
|
||||||
CipurseContext ctx = {0};
|
CipurseContext ctx = {0};
|
||||||
CipurseSetKey(&ctx, 1, key);
|
CipurseSetKey(&ctx, 1, key);
|
||||||
|
|
||||||
|
uint8_t kvv[CIPURSE_KVV_LENGTH] = {0};
|
||||||
|
CipurseCGetKVV(key, kvv);
|
||||||
|
PrintAndLogEx(INFO, "Key: %s KVV: %s", sprint_hex(key, CIPURSE_AES_KEY_LENGTH), sprint_hex_inrow(kvv, CIPURSE_KVV_LENGTH));
|
||||||
|
|
||||||
res = CIPURSEChallenge(buf, sizeof(buf), &len, &sw);
|
res = CIPURSEChallenge(buf, sizeof(buf), &len, &sw);
|
||||||
if (res != 0 || len != 0x16) {
|
if (res != 0 || len != 0x16) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue