cppcheck fix const

This commit is contained in:
iceman1001 2022-01-06 21:53:39 +01:00
commit deb48d2311
10 changed files with 34 additions and 29 deletions

View file

@ -73,7 +73,7 @@ static void transform_D(uint8_t *ru) {
} }
// Transport system (IT) pwd generation algo nickname A. // Transport system (IT) pwd generation algo nickname A.
uint32_t ul_ev1_pwdgenA(uint8_t *uid) { uint32_t ul_ev1_pwdgenA(const uint8_t *uid) {
uint8_t pos = (uid[3] ^ uid[4] ^ uid[5] ^ uid[6]) % 32; uint8_t pos = (uid[3] ^ uid[4] ^ uid[5] ^ uid[6]) % 32;
@ -98,7 +98,7 @@ uint32_t ul_ev1_pwdgenA(uint8_t *uid) {
} }
// Amiibo pwd generation algo nickname B. (very simple) // Amiibo pwd generation algo nickname B. (very simple)
uint32_t ul_ev1_pwdgenB(uint8_t *uid) { uint32_t ul_ev1_pwdgenB(const uint8_t *uid) {
uint8_t pwd[] = {0x00, 0x00, 0x00, 0x00}; uint8_t pwd[] = {0x00, 0x00, 0x00, 0x00};
@ -128,7 +128,7 @@ uint32_t ul_ev1_pwdgenC(uint8_t *uid) {
} }
// XYZ 3d printing pwd generation algo nickname D. // XYZ 3d printing pwd generation algo nickname D.
uint32_t ul_ev1_pwdgenD(uint8_t *uid) { uint32_t ul_ev1_pwdgenD(const uint8_t *uid) {
uint8_t i; uint8_t i;
// rotation offset // rotation offset
@ -153,7 +153,7 @@ uint32_t ul_ev1_pwdgenD(uint8_t *uid) {
} }
// pack generation for algo 1-3 // pack generation for algo 1-3
uint16_t ul_ev1_packgenA(uint8_t *uid) { uint16_t ul_ev1_packgenA(const uint8_t *uid) {
uint16_t pack = (uid[0] ^ uid[1] ^ uid[2]) << 8 | (uid[2] ^ 8); uint16_t pack = (uid[0] ^ uid[1] ^ uid[2]) << 8 | (uid[2] ^ 8);
return pack; return pack;
} }
@ -163,7 +163,7 @@ uint16_t ul_ev1_packgenB(uint8_t *uid) {
uint16_t ul_ev1_packgenC(uint8_t *uid) { uint16_t ul_ev1_packgenC(uint8_t *uid) {
return 0xaa55; return 0xaa55;
} }
uint16_t ul_ev1_packgenD(uint8_t *uid) { uint16_t ul_ev1_packgenD(const uint8_t *uid) {
uint8_t i; uint8_t i;
//Rotate //Rotate
uint8_t r = (uid[2] + uid[5]) & 7; //Rotation offset uint8_t r = (uid[2] + uid[5]) & 7; //Rotation offset
@ -260,7 +260,7 @@ int mfc_algo_saflok_all(uint8_t *uid, uint8_t *keys) {
} }
// MIZIP algo // MIZIP algo
int mfc_algo_mizip_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key) { int mfc_algo_mizip_one(const uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key) {
if (sector > 4) return PM3_EINVARG; if (sector > 4) return PM3_EINVARG;
if (key == NULL) return PM3_EINVARG; if (key == NULL) return PM3_EINVARG;
if (keytype > 2) return PM3_EINVARG; if (keytype > 2) return PM3_EINVARG;

View file

@ -14,16 +14,16 @@
#include "common.h" #include "common.h"
uint32_t ul_ev1_pwdgen_def(uint8_t *uid); uint32_t ul_ev1_pwdgen_def(uint8_t *uid);
uint32_t ul_ev1_pwdgenA(uint8_t *uid); uint32_t ul_ev1_pwdgenA(const uint8_t *uid);
uint32_t ul_ev1_pwdgenB(uint8_t *uid); uint32_t ul_ev1_pwdgenB(const uint8_t *uid);
uint32_t ul_ev1_pwdgenC(uint8_t *uid); uint32_t ul_ev1_pwdgenC(uint8_t *uid);
uint32_t ul_ev1_pwdgenD(uint8_t *uid); uint32_t ul_ev1_pwdgenD(const uint8_t *uid);
uint16_t ul_ev1_packgen_def(uint8_t *uid); uint16_t ul_ev1_packgen_def(uint8_t *uid);
uint16_t ul_ev1_packgenA(uint8_t *uid); uint16_t ul_ev1_packgenA(const uint8_t *uid);
uint16_t ul_ev1_packgenB(uint8_t *uid); uint16_t ul_ev1_packgenB(uint8_t *uid);
uint16_t ul_ev1_packgenC(uint8_t *uid); uint16_t ul_ev1_packgenC(uint8_t *uid);
uint16_t ul_ev1_packgenD(uint8_t *uid); uint16_t ul_ev1_packgenD(const uint8_t *uid);
int mfc_algo_ving_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key); int mfc_algo_ving_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key);
int mfc_algo_ving_all(uint8_t *uid, uint8_t *keys); int mfc_algo_ving_all(uint8_t *uid, uint8_t *keys);
@ -34,7 +34,7 @@ int mfc_algo_yale_all(uint8_t *uid, uint8_t *keys);
int mfc_algo_saflok_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key); int mfc_algo_saflok_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key);
int mfc_algo_saflok_all(uint8_t *uid, uint8_t *keys); int mfc_algo_saflok_all(uint8_t *uid, uint8_t *keys);
int mfc_algo_mizip_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key); int mfc_algo_mizip_one(const uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key);
int mfc_algo_mizip_all(uint8_t *uid, uint8_t *keys); int mfc_algo_mizip_all(uint8_t *uid, uint8_t *keys);
int mfc_algo_di_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key); int mfc_algo_di_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key);

View file

@ -511,7 +511,7 @@ static inline void search_gc_candidates_right(const uint64_t rstate_before_gc, c
} }
} }
static inline void sm_left(const uint8_t *ks, uint8_t *mask, vector<cs_t> *pcstates) { static inline void sm_left(const uint8_t *ks, const uint8_t *mask, vector<cs_t> *pcstates) {
map<uint64_t, cs_t> bincstates; map<uint64_t, cs_t> bincstates;
map<uint64_t, cs_t>::iterator it; map<uint64_t, cs_t>::iterator it;
uint64_t counter, lstate; uint64_t counter, lstate;

View file

@ -481,7 +481,7 @@ static void ice_sm_left_thread(
uint8_t skips, uint8_t skips,
const uint8_t *ks, const uint8_t *ks,
map<uint64_t, cs_t> *bincstates, map<uint64_t, cs_t> *bincstates,
uint8_t *mask const uint8_t *mask
) { ) {
size_t pos, bits; size_t pos, bits;
@ -741,7 +741,7 @@ static inline void search_gc_candidates_right(const uint64_t rstate_before_gc, c
} }
} }
static inline void sm_left(const uint8_t *ks, uint8_t *mask, vector<cs_t> *pcstates) { static inline void sm_left(const uint8_t *ks, const uint8_t *mask, vector<cs_t> *pcstates) {
map<uint64_t, cs_t> bincstates; map<uint64_t, cs_t> bincstates;
map<uint64_t, cs_t>::iterator it; map<uint64_t, cs_t>::iterator it;
uint64_t counter, lstate; uint64_t counter, lstate;

View file

@ -34,7 +34,7 @@ void shexdump(unsigned char *data, int data_len) {
void printbin(unsigned char *c) { void printbin(const unsigned char *c) {
if (!c) { if (!c) {
printf("printbin: invalid params\n"); printf("printbin: invalid params\n");
return; return;

View file

@ -20,7 +20,7 @@
void writebuf(unsigned char *buf, uint64_t val, uint16_t len); void writebuf(unsigned char *buf, uint64_t val, uint16_t len);
void shexdump(unsigned char *data, int data_len); void shexdump(unsigned char *data, int data_len);
void printbin(unsigned char *c); void printbin(const unsigned char *c);
void printbin2(uint64_t val, unsigned int size); void printbin2(uint64_t val, unsigned int size);
void printstate(Hitag_State *hstate); void printstate(Hitag_State *hstate);
unsigned char hex2bin(unsigned char c); unsigned char hex2bin(unsigned char c);

View file

@ -14,8 +14,6 @@ struct rngdata {
int len; int len;
}; };
static int datacmp(const void *p1, const void *p2) { static int datacmp(const void *p1, const void *p2) {
unsigned char *d1 = (unsigned char *)p1; unsigned char *d1 = (unsigned char *)p1;
unsigned char *d2 = (unsigned char *)p2; unsigned char *d2 = (unsigned char *)p2;
@ -116,7 +114,7 @@ static int makecand(unsigned char *c, struct rngdata *r, int bitoffset) {
// test the candidate against the next or previous rng data // test the candidate against the next or previous rng data
static int testcand(unsigned char *f, unsigned char *rt, int fwd) { static int testcand(const unsigned char *f, unsigned char *rt, int fwd) {
Hitag_State hstate; Hitag_State hstate;
int i; int i;
uint32_t ks1; uint32_t ks1;
@ -273,10 +271,7 @@ static int findmatch(struct rngdata *r, unsigned char *outmatch, unsigned char *
return 0; return 0;
} }
static void rollbackrng(Hitag_State *hstate, const unsigned char *s, int offset) {
static void rollbackrng(Hitag_State *hstate, unsigned char *s, int offset) {
int i; int i;
if (!s) { if (!s) {

View file

@ -24,7 +24,8 @@ License: GNU General Public License v3 or any later version (see LICENSE.txt)
#include "opencl.h" #include "opencl.h"
bool plat_dev_enabled(unsigned int id, unsigned int *sel, unsigned int cnt, unsigned int cur_type, unsigned int allow_type) { bool plat_dev_enabled(unsigned int id, const unsigned int *sel,
unsigned int cnt, unsigned int cur_type, unsigned int allow_type) {
// usefulonly with devices // usefulonly with devices
if (allow_type != CL_DEVICE_TYPE_ALL) { if (allow_type != CL_DEVICE_TYPE_ALL) {
if (cur_type != allow_type) return false; if (cur_type != allow_type) return false;
@ -67,7 +68,11 @@ unsigned int get_smallest_profile(compute_platform_ctx_t *cd_ctx, size_t ocl_pla
return profile; return profile;
} }
int discoverDevices(unsigned int profile_selected, uint32_t device_types_selected, cl_uint *platform_detected_cnt, size_t *selected_platforms_cnt, size_t *selected_devices_cnt, compute_platform_ctx_t **cd_ctx, unsigned int *plat_sel, unsigned int plat_cnt, unsigned int *dev_sel, unsigned int dev_cnt, bool verbose, bool show) { int discoverDevices(unsigned int profile_selected, uint32_t device_types_selected,
cl_uint *platform_detected_cnt, size_t *selected_platforms_cnt,
size_t *selected_devices_cnt, compute_platform_ctx_t **cd_ctx,
unsigned int *plat_sel, unsigned int plat_cnt, unsigned int *dev_sel,
unsigned int dev_cnt, bool verbose, bool show) {
int err = 0; int err = 0;
unsigned int ocl_platform_max = MAX_OPENCL_DEVICES; // 16 unsigned int ocl_platform_max = MAX_OPENCL_DEVICES; // 16
cl_uint ocl_platform_cnt; cl_uint ocl_platform_cnt;

View file

@ -121,9 +121,14 @@ typedef struct opencl_ctx {
} opencl_ctx_t; } opencl_ctx_t;
bool plat_dev_enabled(unsigned int id, unsigned int *sel, unsigned int cnt, unsigned int cur_type, unsigned int allow_type); bool plat_dev_enabled(unsigned int id, const unsigned int *sel,
unsigned int cnt, unsigned int cur_type, unsigned int allow_type);
unsigned int get_smallest_profile(compute_platform_ctx_t *cd_ctx, size_t ocl_platform_cnt); unsigned int get_smallest_profile(compute_platform_ctx_t *cd_ctx, size_t ocl_platform_cnt);
int discoverDevices(unsigned int profile_selected, uint32_t device_types_selected, cl_uint *platform_detected_cnt, size_t *selected_platforms_cnt, size_t *selected_devices_cnt, compute_platform_ctx_t **cd_ctx, unsigned int *plat_sel, unsigned int plat_cnt, unsigned int *dev_sel, unsigned int dev_cnt, bool verbose, bool show); int discoverDevices(unsigned int profile_selected, uint32_t device_types_selected,
cl_uint *platform_detected_cnt, size_t *selected_platforms_cnt,
size_t *selected_devices_cnt, compute_platform_ctx_t **cd_ctx,
unsigned int *plat_sel, unsigned int plat_cnt, unsigned int *dev_sel,
unsigned int dev_cnt, bool verbose, bool show);
int runKernel(opencl_ctx_t *ctx, uint32_t cand_base, uint64_t *matches, uint32_t *matches_found, size_t id); int runKernel(opencl_ctx_t *ctx, uint32_t cand_base, uint64_t *matches, uint32_t *matches_found, size_t id);
#endif // OPENCL_H #endif // OPENCL_H

View file

@ -463,7 +463,7 @@ static void *brute_thread(void *arguments) {
static void *brute_key_thread(void *arguments) { static void *brute_key_thread(void *arguments) {
struct thread_key_args *args = (struct thread_key_args *) arguments; struct thread_key_args *args = (struct thread_key_args *) arguments;
uint64_t key = args->part_key; uint64_t key;
uint8_t local_enc[args->enc_len]; uint8_t local_enc[args->enc_len];
memcpy(local_enc, args->enc, args->enc_len); memcpy(local_enc, args->enc, args->enc_len);