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
/
gcrypt
/
rsagen.c
diff --git
a/src/gcrypt/rsagen.c
b/src/gcrypt/rsagen.c
index
acf96ac
..
3469c33
100644
(file)
--- a/
src/gcrypt/rsagen.c
+++ b/
src/gcrypt/rsagen.c
@@
-1,6
+1,6
@@
/*
rsagen.c -- RSA key generation and export
/*
rsagen.c -- RSA key generation and export
- Copyright (C) 2008-20
1
2 Guus Sliepen <guus@tinc-vpn.org>
+ Copyright (C) 2008-20
2
2 Guus Sliepen <guus@tinc-vpn.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-17,21
+17,17
@@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "system.h"
+#include "
../
system.h"
#include <gcrypt.h>
#include <assert.h>
#include <gcrypt.h>
#include <assert.h>
-#include "../rsagen.h"
-#include "xalloc.h"
+#include "asn1.h"
#include "rsa.h"
#include "pem.h"
#include "rsa.h"
#include "pem.h"
-
-// ASN.1 tags.
-typedef enum {
- TAG_INTEGER = 2,
- TAG_SEQUENCE = 16,
-} asn1_tag_t;
+#include "../rsagen.h"
+#include "../xalloc.h"
+#include "../utils.h"
static size_t der_tag_len(size_t n) {
if(n < 128) {
static size_t der_tag_len(size_t n) {
if(n < 128) {
@@
-106,7
+102,7
@@
static size_t der_fill(uint8_t *derbuf, bool is_private, const gcry_mpi_t mpi[],
der += len;
}
der += len;
}
- assert(
der - derbuf
== derlen);
+ assert(
(size_t)(der - derbuf)
== derlen);
return derlen;
}
return derlen;
}
@@
-240,7
+236,9
@@
bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp) {
gcry_mpi_release(params[dq]);
gcry_mpi_release(params[u]);
gcry_mpi_release(params[dq]);
gcry_mpi_release(params[u]);
- return pem_encode(fp, "RSA PRIVATE KEY", derbuf, derlen);
+ bool success = pem_encode(fp, "RSA PRIVATE KEY", derbuf, derlen);
+ memzero(derbuf, sizeof(derbuf));
+ return success;
}
static gcry_mpi_t find_mpi(const gcry_sexp_t rsa, const char *token) {
}
static gcry_mpi_t find_mpi(const gcry_sexp_t rsa, const char *token) {
@@
-299,7
+297,7
@@
rsa_t *rsa_generate(size_t bits, unsigned long exponent) {
return NULL;
}
return NULL;
}
- rsa_t *rsa =
xzalloc(sizeof(*rsa)
);
+ rsa_t *rsa =
rsa_new(
);
rsa->n = find_mpi(s_rsa, "n");
rsa->e = find_mpi(s_rsa, "e");
rsa->n = find_mpi(s_rsa, "n");
rsa->e = find_mpi(s_rsa, "e");