mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
code style, code clean up of redundant functions, comments, its many minor fixes across the platform. Sorry for not making 20 commits
This commit is contained in:
parent
6bb7199a7b
commit
cef07dedf6
57 changed files with 672 additions and 521 deletions
|
@ -17,6 +17,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "commonutil.h"
|
||||
#include <string.h>
|
||||
#include "stdbool.h"
|
||||
|
||||
/* Similar to FpgaGatherVersion this formats stored version information
|
||||
* into a string representation. It takes a pointer to the struct version_information_t,
|
||||
|
@ -403,25 +404,34 @@ void Uint8byteToMemBe(uint8_t *data, uint64_t value) {
|
|||
}
|
||||
|
||||
// Rotate Left - Ultralight, Desfire
|
||||
void rol(uint8_t *data, const size_t len) {
|
||||
void rol(uint8_t *data, const size_t n) {
|
||||
uint8_t first = data[0];
|
||||
for (size_t i = 0; i < len - 1; i++) {
|
||||
for (size_t i = 0; i < n - 1; i++) {
|
||||
data[i] = data[i + 1];
|
||||
}
|
||||
data[len - 1] = first;
|
||||
data[n - 1] = first;
|
||||
}
|
||||
|
||||
// Rotate Right - Ultralight, Desfire
|
||||
void ror(uint8_t *data, const size_t len) {
|
||||
uint8_t last = data[len - 1];
|
||||
void ror(uint8_t *data, const size_t n) {
|
||||
uint8_t last = data[n - 1];
|
||||
|
||||
for (int i = len - 1; i > 0; i--) {
|
||||
for (int i = n - 1; i > 0; i--) {
|
||||
data[i] = data[i - 1];
|
||||
}
|
||||
|
||||
data[0] = last;
|
||||
}
|
||||
|
||||
void xor(uint8_t *dest, const uint8_t *src, size_t n) {
|
||||
|
||||
const uint8_t *s = src;
|
||||
uint8_t *d = dest;
|
||||
|
||||
for (; n > 0; n--) {
|
||||
*d++ ^= *s++;
|
||||
}
|
||||
}
|
||||
|
||||
void lsl(uint8_t *data, size_t len) {
|
||||
for (size_t n = 0; n < len - 1; n++) {
|
||||
|
|
|
@ -128,8 +128,9 @@ void Uint7byteToMemBe(uint8_t *data, uint64_t value);
|
|||
void Uint8byteToMemBe(uint8_t *data, uint64_t value);
|
||||
|
||||
// rotate left byte array
|
||||
void rol(uint8_t *data, const size_t len);
|
||||
void ror(uint8_t *data, const size_t len);
|
||||
void rol(uint8_t *data, const size_t n);
|
||||
void ror(uint8_t *data, const size_t n);
|
||||
void xor(uint8_t *dest, const uint8_t *src, size_t n);
|
||||
|
||||
void lsl(uint8_t *data, size_t len);
|
||||
uint32_t le24toh(const uint8_t data[3]);
|
||||
|
|
|
@ -321,11 +321,11 @@ static int asn1_get_sequence_of_cb(void *ctx,
|
|||
cb_ctx->cur;
|
||||
|
||||
if (cur->buf.p != NULL) {
|
||||
cur->next =
|
||||
mbedtls_calloc(1, sizeof(mbedtls_asn1_sequence));
|
||||
cur->next = mbedtls_calloc(1, sizeof(mbedtls_asn1_sequence));
|
||||
|
||||
if (cur->next == NULL)
|
||||
if (cur->next == NULL) {
|
||||
return (MBEDTLS_ERR_ASN1_ALLOC_FAILED);
|
||||
}
|
||||
|
||||
cur = cur->next;
|
||||
}
|
||||
|
|
|
@ -180,8 +180,7 @@ int mbedtls_cipher_cmac_starts(mbedtls_cipher_context_t *ctx,
|
|||
if (ctx == NULL || ctx->cipher_info == NULL || key == NULL)
|
||||
return (MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA);
|
||||
|
||||
if ((retval = mbedtls_cipher_setkey(ctx, key, (int)keybits,
|
||||
MBEDTLS_ENCRYPT)) != 0)
|
||||
if ((retval = mbedtls_cipher_setkey(ctx, key, (int)keybits, MBEDTLS_ENCRYPT)) != 0)
|
||||
return (retval);
|
||||
|
||||
type = ctx->cipher_info->type;
|
||||
|
@ -405,14 +404,12 @@ int mbedtls_aes_cmac_prf_128(const unsigned char *key, size_t key_length,
|
|||
} else {
|
||||
memset(zero_key, 0, MBEDTLS_AES_BLOCK_SIZE);
|
||||
|
||||
ret = mbedtls_cipher_cmac(cipher_info, zero_key, 128, key,
|
||||
key_length, int_key);
|
||||
ret = mbedtls_cipher_cmac(cipher_info, zero_key, 128, key, key_length, int_key);
|
||||
if (ret != 0)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ret = mbedtls_cipher_cmac(cipher_info, int_key, 128, input, in_len,
|
||||
output);
|
||||
ret = mbedtls_cipher_cmac(cipher_info, int_key, 128, input, in_len, output);
|
||||
|
||||
exit:
|
||||
mbedtls_platform_zeroize(int_key, sizeof(int_key));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue