aboutsummaryrefslogtreecommitdiff
path: root/src/mint/mint_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mint/mint_common.c')
-rw-r--r--src/mint/mint_common.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/mint/mint_common.c b/src/mint/mint_common.c
index 734085e7b..bb55f30c4 100644
--- a/src/mint/mint_common.c
+++ b/src/mint/mint_common.c
@@ -93,7 +93,7 @@ TALER_MINT_read_denom_key (const char *filename,
93 uint64_t size; 93 uint64_t size;
94 size_t offset; 94 size_t offset;
95 void *data; 95 void *data;
96 struct TALER_RSA_PrivateKey *priv; 96 struct GNUNET_CRYPTO_rsa_PrivateKey *priv;
97 int ret; 97 int ret;
98 98
99 ret = GNUNET_SYSERR; 99 ret = GNUNET_SYSERR;
@@ -115,7 +115,8 @@ TALER_MINT_read_denom_key (const char *filename,
115 data, 115 data,
116 size)) 116 size))
117 goto cleanup; 117 goto cleanup;
118 if (NULL == (priv = TALER_RSA_decode_key (data + offset, size - offset))) 118 if (NULL == (priv = GNUNET_CRYPTO_rsa_private_key_decode (data + offset,
119 size - offset)))
119 goto cleanup; 120 goto cleanup;
120 dki->denom_priv = priv; 121 dki->denom_priv = priv;
121 memcpy (&dki->issue.signature, data, offset); 122 memcpy (&dki->issue.signature, data, offset);
@@ -138,22 +139,22 @@ int
138TALER_MINT_write_denom_key (const char *filename, 139TALER_MINT_write_denom_key (const char *filename,
139 const struct TALER_MINT_DenomKeyIssuePriv *dki) 140 const struct TALER_MINT_DenomKeyIssuePriv *dki)
140{ 141{
141 struct TALER_RSA_PrivateKeyBinaryEncoded *priv_enc; 142 char *priv_enc;
143 size_t priv_enc_size;
142 struct GNUNET_DISK_FileHandle *fh; 144 struct GNUNET_DISK_FileHandle *fh;
143 ssize_t wrote; 145 ssize_t wrote;
144 size_t wsize; 146 size_t wsize;
145 int ret; 147 int ret;
146 148
147 fh = NULL; 149 fh = NULL;
148 priv_enc = NULL; 150 priv_enc_size = GNUNET_CRYPTO_rsa_private_key_encode (dki->denom_priv,
151 &priv_enc);
149 ret = GNUNET_SYSERR; 152 ret = GNUNET_SYSERR;
150 if (NULL == (fh = GNUNET_DISK_file_open 153 if (NULL == (fh = GNUNET_DISK_file_open
151 (filename, 154 (filename,
152 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_TRUNCATE, 155 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_TRUNCATE,
153 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE))) 156 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)))
154 goto cleanup; 157 goto cleanup;
155 if (NULL == (priv_enc = TALER_RSA_encode_key (dki->denom_priv)))
156 goto cleanup;
157 wsize = sizeof (struct TALER_MINT_DenomKeyIssuePriv) 158 wsize = sizeof (struct TALER_MINT_DenomKeyIssuePriv)
158 - offsetof (struct TALER_MINT_DenomKeyIssuePriv, issue.signature); 159 - offsetof (struct TALER_MINT_DenomKeyIssuePriv, issue.signature);
159 if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh, 160 if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh,
@@ -162,12 +163,11 @@ TALER_MINT_write_denom_key (const char *filename,
162 goto cleanup; 163 goto cleanup;
163 if (wrote != wsize) 164 if (wrote != wsize)
164 goto cleanup; 165 goto cleanup;
165 wsize = ntohs (priv_enc->len);
166 if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh, 166 if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh,
167 priv_enc, 167 priv_enc,
168 wsize))) 168 priv_enc_size)))
169 goto cleanup; 169 goto cleanup;
170 if (wrote != wsize) 170 if (wrote != priv_enc_size)
171 goto cleanup; 171 goto cleanup;
172 ret = GNUNET_OK; 172 ret = GNUNET_OK;
173 cleanup: 173 cleanup: