aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_rsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/crypto_rsa.c')
-rw-r--r--src/util/crypto_rsa.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c
index 7bffa71ee..9da95a56e 100644
--- a/src/util/crypto_rsa.c
+++ b/src/util/crypto_rsa.c
@@ -186,15 +186,15 @@ key_from_sexp (gcry_mpi_t * array,
186 186
187/** 187/**
188 * Extract the public key of the host. 188 * Extract the public key of the host.
189 * @param hostkey the hostkey to extract into the result. 189 * @param priv the private key
190 * @param result where to write the result. 190 * @param pub where to write the public key
191 */ 191 */
192void 192void
193GNUNET_CRYPTO_rsa_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey 193GNUNET_CRYPTO_rsa_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey
194 *hostkey, 194 *priv,
195 struct 195 struct
196 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 196 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
197 *result) 197 *pub)
198{ 198{
199 gcry_mpi_t skey[2]; 199 gcry_mpi_t skey[2];
200 size_t size; 200 size_t size;
@@ -750,15 +750,15 @@ GNUNET_CRYPTO_rsa_encrypt (const void *block,
750/** 750/**
751 * Decrypt a given block with the hostkey. 751 * Decrypt a given block with the hostkey.
752 * 752 *
753 * @param hostkey the hostkey with which to decrypt this block 753 * @param key the key with which to decrypt this block
754 * @param block the data to decrypt, encoded as returned by encrypt 754 * @param block the data to decrypt, encoded as returned by encrypt
755 * @param result pointer to a location where the result can be stored 755 * @param result pointer to a location where the result can be stored
756 * @param max the maximum number of bits to store for the result, if 756 * @param max the maximum number of bits to store for the result, if
757 * the decrypted block is bigger, an error is returned 757 * the decrypted block is bigger, an error is returned
758 * @returns the size of the decrypted block, -1 on error 758 * @return the size of the decrypted block, -1 on error
759 */ 759 */
760ssize_t 760ssize_t
761GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey, 761GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
762 const struct GNUNET_CRYPTO_RsaEncryptedData *block, 762 const struct GNUNET_CRYPTO_RsaEncryptedData *block,
763 void *result, 763 void *result,
764 size_t max) 764 size_t max)
@@ -772,7 +772,7 @@ GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey,
772 unsigned char *tmp; 772 unsigned char *tmp;
773 773
774#if EXTRA_CHECKS 774#if EXTRA_CHECKS
775 GNUNET_assert (0 == gcry_pk_testkey (hostkey->sexp)); 775 GNUNET_assert (0 == gcry_pk_testkey (key->sexp));
776#endif 776#endif
777 size = sizeof (struct GNUNET_CRYPTO_RsaEncryptedData); 777 size = sizeof (struct GNUNET_CRYPTO_RsaEncryptedData);
778 GNUNET_assert (0 == gcry_mpi_scan (&val, 778 GNUNET_assert (0 == gcry_mpi_scan (&val,
@@ -782,7 +782,7 @@ GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey,
782 gcry_sexp_build (&data, &erroff, 782 gcry_sexp_build (&data, &erroff,
783 "(enc-val(flags)(rsa(a %m)))", val)); 783 "(enc-val(flags)(rsa(a %m)))", val));
784 gcry_mpi_release (val); 784 gcry_mpi_release (val);
785 GNUNET_assert (0 == gcry_pk_decrypt (&resultsexp, data, hostkey->sexp)); 785 GNUNET_assert (0 == gcry_pk_decrypt (&resultsexp, data, key->sexp));
786 gcry_sexp_release (data); 786 gcry_sexp_release (data);
787 /* resultsexp has format "(value %m)" */ 787 /* resultsexp has format "(value %m)" */
788 GNUNET_assert (NULL != 788 GNUNET_assert (NULL !=
@@ -805,13 +805,13 @@ GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey,
805/** 805/**
806 * Sign a given block. 806 * Sign a given block.
807 * 807 *
808 * @param hostkey private key to use for the signing 808 * @param key private key to use for the signing
809 * @param purpose what to sign (size, purpose) 809 * @param purpose what to sign (size, purpose)
810 * @param sig where to write the signature 810 * @param sig where to write the signature
811 * @return GNUNET_SYSERR on error, GNUNET_OK on success 811 * @return GNUNET_SYSERR on error, GNUNET_OK on success
812 */ 812 */
813int 813int
814GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey, 814GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
815 const struct GNUNET_CRYPTO_RsaSignaturePurpose 815 const struct GNUNET_CRYPTO_RsaSignaturePurpose
816 *purpose, struct GNUNET_CRYPTO_RsaSignature *sig) 816 *purpose, struct GNUNET_CRYPTO_RsaSignature *sig)
817{ 817{
@@ -835,7 +835,7 @@ GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey,
835 - 1], &hc, sizeof (GNUNET_HashCode)); 835 - 1], &hc, sizeof (GNUNET_HashCode));
836 GNUNET_assert (0 == gcry_sexp_new (&data, buff, bufSize, 0)); 836 GNUNET_assert (0 == gcry_sexp_new (&data, buff, bufSize, 0));
837 GNUNET_free (buff); 837 GNUNET_free (buff);
838 GNUNET_assert (0 == gcry_pk_sign (&result, data, hostkey->sexp)); 838 GNUNET_assert (0 == gcry_pk_sign (&result, data, key->sexp));
839 gcry_sexp_release (data); 839 gcry_sexp_release (data);
840 GNUNET_assert (0 == key_from_sexp (&rval, result, "rsa", "s")); 840 GNUNET_assert (0 == key_from_sexp (&rval, result, "rsa", "s"));
841 gcry_sexp_release (result); 841 gcry_sexp_release (result);