Merge pull request #3276 from kormax/duox-cleanup

DUOX-related cleanup
This commit is contained in:
Iceman
2026-04-30 17:22:51 +07:00
committed by GitHub
3 changed files with 219 additions and 194 deletions
+201 -194
View File
File diff suppressed because it is too large Load Diff
+17
View File
@@ -89,6 +89,23 @@ int pcrypto_rng_fill(pcrypto_rng_t *rng, uint8_t *out, size_t out_len) {
return (mbedtls_ctr_drbg_random(&rng->ctr_drbg, out, out_len) == 0) ? PM3_SUCCESS : PM3_ESOFT;
}
int pcrypto_rng_fill_oneshot(uint8_t *out, size_t out_len, const char *personalization) {
if (out == NULL || personalization == NULL) {
return PM3_EINVARG;
}
pcrypto_rng_t rng = {0};
int res = pcrypto_rng_init(&rng, (const uint8_t *)personalization, strlen(personalization));
if (res != PM3_SUCCESS) {
pcrypto_rng_free(&rng);
return res;
}
res = pcrypto_rng_fill(&rng, out, out_len);
pcrypto_rng_free(&rng);
return res;
}
static void pcrypto_trim_ascii_inplace(char *text) {
if (text == NULL) {
return;
+1
View File
@@ -38,6 +38,7 @@ typedef struct {
int pcrypto_rng_init(pcrypto_rng_t *rng, const uint8_t *personalization, size_t personalization_len);
void pcrypto_rng_free(pcrypto_rng_t *rng);
int pcrypto_rng_fill(pcrypto_rng_t *rng, uint8_t *out, size_t out_len);
int pcrypto_rng_fill_oneshot(uint8_t *out, size_t out_len, const char *personalization);
void des_encrypt(void *out, const void *in, const void *key);
void des_decrypt(void *out, const void *in, const void *key);