fix: generate random nonce
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <aes.h>
|
#include <aes.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "hwinfo.h"
|
#include "hwinfo.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@@ -63,6 +64,23 @@ int main(int argc, char** argv) {
|
|||||||
struct AES_ctx ctx;
|
struct AES_ctx ctx;
|
||||||
uint8_t nonce[16] = {0};
|
uint8_t nonce[16] = {0};
|
||||||
|
|
||||||
|
time_t ts = time(NULL);
|
||||||
|
srand(ts);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < sizeof(nonce); i+= 4) {
|
||||||
|
uint32_t random = rand();
|
||||||
|
nonce[i + 0] = random & 0xFF;
|
||||||
|
nonce[i + 1] = (random >> 8) & 0xFF;
|
||||||
|
nonce[i + 2] = (random >> 16) & 0xFF;
|
||||||
|
nonce[i + 3] = (random >> 24) & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Nonce: ");
|
||||||
|
for (size_t i = 0; i < sizeof(nonce); i++) {
|
||||||
|
fprintf(stderr, "%02X", nonce[i]);
|
||||||
|
}
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
FILE* license = fopen(input, "rb");
|
FILE* license = fopen(input, "rb");
|
||||||
long data_start = ftell(license);
|
long data_start = ftell(license);
|
||||||
fseek(license, 0, SEEK_END);
|
fseek(license, 0, SEEK_END);
|
||||||
|
|||||||
Reference in New Issue
Block a user