aboutsummaryrefslogtreecommitdiff
path: root/src/util/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/util.c')
-rw-r--r--src/util/util.c45
1 files changed, 4 insertions, 41 deletions
diff --git a/src/util/util.c b/src/util/util.c
index 3677bcbde..ac3cd1428 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -17,7 +17,7 @@
17/** 17/**
18 * @file util.c 18 * @file util.c
19 * @brief Common utility functions 19 * @brief Common utility functions
20 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 20 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
21 * @author Florian Dold 21 * @author Florian Dold
22 * @author Benedikt Mueller 22 * @author Benedikt Mueller
23 */ 23 */
@@ -59,43 +59,6 @@ TALER_gcrypt_init()
59 59
60 60
61/** 61/**
62 * Generate a ECC private key.
63 *
64 * @return the s-expression representing the generated ECC private key; NULL
65 * upon error
66 */
67gcry_sexp_t
68TALER_genkey ()
69{
70 gcry_sexp_t priv_sexp;
71 gcry_sexp_t s_keyparam;
72 int rc;
73
74 if (0 != (rc = gcry_sexp_build (&s_keyparam, NULL,
75 "(genkey(ecc(curve \"" CURVE "\")"
76 "(flags eddsa)))")))
77 {
78 LOG_GCRY_ERROR ("gcry_sexp_build", rc);
79 return NULL;
80 }
81 if (0 != (rc = gcry_pk_genkey (&priv_sexp, s_keyparam)))
82 {
83 LOG_GCRY_ERROR ("gcry_pk_genkey", rc);
84 gcry_sexp_release (s_keyparam);
85 return NULL;
86 }
87 gcry_sexp_release (s_keyparam);
88 if (0 != (rc = gcry_pk_testkey (priv_sexp)))
89 {
90 LOG_GCRY_ERROR("gcry_pk_testkey", rc);
91 gcry_sexp_release (priv_sexp);
92 return NULL;
93 }
94 return priv_sexp;
95}
96
97
98/**
99 * Parse money amount description, in the format "A:B.C". 62 * Parse money amount description, in the format "A:B.C".
100 * 63 *
101 * @param str amount description 64 * @param str amount description
@@ -123,7 +86,7 @@ TALER_string_to_amount (const char *str, struct TALER_Amount *denom)
123 printf("null before currency\n"); 86 printf("null before currency\n");
124 return GNUNET_SYSERR; 87 return GNUNET_SYSERR;
125 } 88 }
126 89
127 while (str[i] != ':') 90 while (str[i] != ':')
128 { 91 {
129 if (0 == str[i]) 92 if (0 == str[i])
@@ -197,7 +160,7 @@ TALER_string_to_amount (const char *str, struct TALER_Amount *denom)
197/** 160/**
198 * FIXME 161 * FIXME
199 */ 162 */
200struct TALER_AmountNBO 163struct TALER_AmountNBO
201TALER_amount_hton (struct TALER_Amount d) 164TALER_amount_hton (struct TALER_Amount d)
202{ 165{
203 struct TALER_AmountNBO dn; 166 struct TALER_AmountNBO dn;
@@ -462,7 +425,7 @@ derive_refresh_key (const struct GNUNET_HashCode *secret,
462 static const char ctx_key[] = "taler-key-skey"; 425 static const char ctx_key[] = "taler-key-skey";
463 static const char ctx_iv[] = "taler-key-iv"; 426 static const char ctx_iv[] = "taler-key-iv";
464 427
465 GNUNET_assert (GNUNET_YES == 428 GNUNET_assert (GNUNET_YES ==
466 GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey), 429 GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey),
467 ctx_key, strlen (ctx_key), 430 ctx_key, strlen (ctx_key),
468 secret, sizeof (struct GNUNET_HashCode), 431 secret, sizeof (struct GNUNET_HashCode),