projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Ensure we are compatible with LibreSSL.
[tinc]
/
src
/
ed25519
/
ecdsagen.c
diff --git
a/src/ed25519/ecdsagen.c
b/src/ed25519/ecdsagen.c
index
5120f28
..
1edc945
100644
(file)
--- a/
src/ed25519/ecdsagen.c
+++ b/
src/ed25519/ecdsagen.c
@@
-27,10
+27,10
@@
typedef struct {
uint8_t public[32];
} ecdsa_t;
uint8_t public[32];
} ecdsa_t;
-#include "../crypto.h"
#include "../ecdsagen.h"
#include "../utils.h"
#include "../xalloc.h"
#include "../ecdsagen.h"
#include "../utils.h"
#include "../xalloc.h"
+#include "../random.h"
// Generate ECDSA key
// Generate ECDSA key
@@
-40,24
+40,29
@@
ecdsa_t *ecdsa_generate(void) {
uint8_t seed[32];
randomize(seed, sizeof(seed));
ed25519_create_keypair(ecdsa->public, ecdsa->private, seed);
uint8_t seed[32];
randomize(seed, sizeof(seed));
ed25519_create_keypair(ecdsa->public, ecdsa->private, seed);
+ memzero(seed, sizeof(seed));
return ecdsa;
}
// Write PEM ECDSA keys
return ecdsa;
}
// Write PEM ECDSA keys
-static bool write_pem(FILE *fp, const char *type, void *buf, size_t size) {
+static bool write_pem(FILE *fp, const char *type, void *
v
buf, size_t size) {
fprintf(fp, "-----BEGIN %s-----\n", type);
fprintf(fp, "-----BEGIN %s-----\n", type);
+ char *buf = vbuf;
char base64[65];
char base64[65];
+
while(size) {
size_t todo = size > 48 ? 48 : size;
while(size) {
size_t todo = size > 48 ? 48 : size;
- b64encode(buf, base64, todo);
+ b64encode
_tinc
(buf, base64, todo);
fprintf(fp, "%s\n", base64);
buf += todo;
size -= todo;
}
fprintf(fp, "%s\n", base64);
buf += todo;
size -= todo;
}
+ memzero(base64, sizeof(base64));
+
fprintf(fp, "-----END %s-----\n", type);
return !ferror(fp);
}
fprintf(fp, "-----END %s-----\n", type);
return !ferror(fp);
}