gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35730 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r35730 - in gnunet/src: include util
Date: Fri, 15 May 2015 14:15:58 +0200

Author: grothoff
Date: 2015-05-15 14:15:58 +0200 (Fri, 15 May 2015)
New Revision: 35730

Modified:
   gnunet/src/include/gnunet_crypto_lib.h
   gnunet/src/util/crypto_rsa.c
Log:
-adding cmp functions for RSA public keys and sigs

Modified: gnunet/src/include/gnunet_crypto_lib.h
===================================================================
--- gnunet/src/include/gnunet_crypto_lib.h      2015-05-13 16:19:10 UTC (rev 
35729)
+++ gnunet/src/include/gnunet_crypto_lib.h      2015-05-15 12:15:58 UTC (rev 
35730)
@@ -1682,6 +1682,30 @@
 
 
 /**
+ * Compare the values of two signatures.
+ *
+ * @param s1 one signature
+ * @param s2 the other signature
+ * @return 0 if the two are equal
+ */
+int
+GNUNET_CRYPTO_rsa_signature_cmp (struct GNUNET_CRYPTO_rsa_Signature *s1,
+                                struct GNUNET_CRYPTO_rsa_Signature *s2);
+
+
+/**
+ * Compare the values of two public keys.
+ *
+ * @param p1 one public key
+ * @param p2 the other public key
+ * @return 0 if the two are equal
+ */
+int
+GNUNET_CRYPTO_rsa_public_key_cmp (struct GNUNET_CRYPTO_rsa_PublicKey *p1,
+                                 struct GNUNET_CRYPTO_rsa_PublicKey *p2);
+
+
+/**
  * Destroy a blinding key
  *
  * @param bkey the blinding key to destroy

Modified: gnunet/src/util/crypto_rsa.c
===================================================================
--- gnunet/src/util/crypto_rsa.c        2015-05-13 16:19:10 UTC (rev 35729)
+++ gnunet/src/util/crypto_rsa.c        2015-05-15 12:15:58 UTC (rev 35730)
@@ -422,6 +422,72 @@
 
 
 /**
+ * Compare the values of two signatures.
+ *
+ * @param s1 one signature
+ * @param s2 the other signature
+ * @return 0 if the two are equal
+ */
+int
+GNUNET_CRYPTO_rsa_signature_cmp (struct GNUNET_CRYPTO_rsa_Signature *s1,
+                                struct GNUNET_CRYPTO_rsa_Signature *s2)
+{
+  char *b1;
+  char *b2;
+  size_t z1;
+  size_t z2;
+  int ret;
+  
+  z1 = GNUNET_CRYPTO_rsa_signature_encode (s1,
+                                          &b1);
+  z2 = GNUNET_CRYPTO_rsa_signature_encode (s2,
+                                          &b2);
+  if (z1 != z2)
+    ret = 1;
+  else
+    ret = memcmp (b1,
+                 b2,
+                 z1);
+  GNUNET_free (b1);
+  GNUNET_free (b2);
+  return ret;
+}
+
+
+/**
+ * Compare the values of two public keys.
+ *
+ * @param p1 one public key
+ * @param p2 the other public key
+ * @return 0 if the two are equal
+ */
+int
+GNUNET_CRYPTO_rsa_public_key_cmp (struct GNUNET_CRYPTO_rsa_PublicKey *p1,
+                                 struct GNUNET_CRYPTO_rsa_PublicKey *p2)
+{
+  char *b1;
+  char *b2;
+  size_t z1;
+  size_t z2;
+  int ret;
+  
+  z1 = GNUNET_CRYPTO_rsa_public_key_encode (p1,
+                                           &b1);
+  z2 = GNUNET_CRYPTO_rsa_public_key_encode (p2,
+                                           &b2);
+  if (z1 != z2)
+    ret = 1;
+  else
+    ret = memcmp (b1,
+                 b2,
+                 z1);
+  GNUNET_free (b1);
+  GNUNET_free (b2);
+  return ret;
+}
+
+
+/**
  * Destroy a blinding key
  *
  * @param bkey the blinding key to destroy
@@ -618,8 +684,8 @@
  */
 struct GNUNET_CRYPTO_rsa_Signature *
 GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_rsa_PrivateKey *key,
-                const void *msg,
-                size_t msg_len)
+                       const void *msg,
+                       size_t msg_len)
 {
   struct GNUNET_CRYPTO_rsa_Signature *sig;
   gcry_sexp_t result;
@@ -664,7 +730,7 @@
  */
 size_t
 GNUNET_CRYPTO_rsa_signature_encode (const struct GNUNET_CRYPTO_rsa_Signature 
*sig,
-                            char **buffer)
+                                   char **buffer)
 {
   size_t n;
   char *b;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]