aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_crypto_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-07-06 14:22:51 +0000
committerChristian Grothoff <christian@grothoff.org>2015-07-06 14:22:51 +0000
commit0f9e6bcd1e511abae16ecc4c86056b0c26d73936 (patch)
tree4ba3af76391ee6c67563316de29b6ad8830cd7f2 /src/include/gnunet_crypto_lib.h
parentf1e619572751f7652db025f66f119d6a0308114b (diff)
downloadgnunet-0f9e6bcd1e511abae16ecc4c86056b0c26d73936.tar.gz
gnunet-0f9e6bcd1e511abae16ecc4c86056b0c26d73936.zip
-fix non-deterministic peerstore sync failure
Diffstat (limited to 'src/include/gnunet_crypto_lib.h')
-rw-r--r--src/include/gnunet_crypto_lib.h84
1 files changed, 82 insertions, 2 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 3ee8ea5a7..38a3ab3b6 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -1297,20 +1297,100 @@ GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max,
1297 unsigned int mem); 1297 unsigned int mem);
1298 1298
1299 1299
1300
1301/** 1300/**
1302 * Calculate ECC discrete logarithm for small factors. 1301 * Calculate ECC discrete logarithm for small factors.
1302 * Opposite of #GNUNET_CRYPTO_ecc_dexp().
1303 * 1303 *
1304 * @param dlc precalculated values, determine range of factors 1304 * @param dlc precalculated values, determine range of factors
1305 * @param input point on the curve to factor 1305 * @param input point on the curve to factor
1306 * @return `dlc->max` if dlog failed, otherwise the factor 1306 * @return `dlc->max` if dlog failed, otherwise the factor
1307 */ 1307 */
1308unsigned int 1308int
1309GNUNET_CRYPTO_ecc_dlog (struct GNUNET_CRYPTO_EccDlogContext *edc, 1309GNUNET_CRYPTO_ecc_dlog (struct GNUNET_CRYPTO_EccDlogContext *edc,
1310 gcry_mpi_point_t input); 1310 gcry_mpi_point_t input);
1311 1311
1312 1312
1313/** 1313/**
1314 * Multiply the generator g of the elliptic curve by @a val
1315 * to obtain the point on the curve representing @a val.
1316 * Afterwards, point addition will correspond to integer
1317 * addition. #GNUNET_CRYPTO_ecc_dlog() can be used to
1318 * convert a point back to an integer (as long as the
1319 * integer is smaller than the MAX of the @a edc context).
1320 *
1321 * @param edc calculation context for ECC operations
1322 * @param val value to encode into a point
1323 * @return representation of the value as an ECC point,
1324 * must be freed using #GNUNET_CRYPTO_ecc_free()
1325 */
1326gcry_mpi_point_t
1327GNUNET_CRYPTO_ecc_dexp (struct GNUNET_CRYPTO_EccDlogContext *edc,
1328 int val);
1329
1330
1331/**
1332 * Multiply the generator g of the elliptic curve by @a val
1333 * to obtain the point on the curve representing @a val.
1334 *
1335 * @param edc calculation context for ECC operations
1336 * @param val (positive) value to encode into a point
1337 * @return representation of the value as an ECC point,
1338 * must be freed using #GNUNET_CRYPTO_ecc_free()
1339 */
1340gcry_mpi_point_t
1341GNUNET_CRYPTO_ecc_dexp_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc,
1342 gcry_mpi_t val);
1343
1344
1345/**
1346 * Add two points on the elliptic curve.
1347 *
1348 * @param edc calculation context for ECC operations
1349 * @param a some value
1350 * @param b some value
1351 * @return @a a + @a b, must be freed using #GNUNET_CRYPTO_ecc_free()
1352 */
1353gcry_mpi_point_t
1354GNUNET_CRYPTO_ecc_add (struct GNUNET_CRYPTO_EccDlogContext *edc,
1355 gcry_mpi_point_t a,
1356 gcry_mpi_point_t b);
1357
1358
1359/**
1360 * Obtain a random point on the curve and its
1361 * additive inverse. Both returned values
1362 * must be freed using #GNUNET_CRYPTO_ecc_free().
1363 *
1364 * @param edc calculation context for ECC operations
1365 * @param[out] r set to a random point on the curve
1366 * @param[out] r_inv set to the additive inverse of @a r
1367 */
1368void
1369GNUNET_CRYPTO_ecc_rnd (struct GNUNET_CRYPTO_EccDlogContext *edc,
1370 gcry_mpi_point_t *r,
1371 gcry_mpi_point_t *r_inv);
1372
1373
1374/**
1375 * Generate a random value mod n.
1376 *
1377 * @param edc ECC context
1378 * @return random value mod n.
1379 */
1380gcry_mpi_t
1381GNUNET_CRYPTO_ecc_random_mod_n (struct GNUNET_CRYPTO_EccDlogContext *edc);
1382
1383
1384/**
1385 * Free a point value returned by the API.
1386 *
1387 * @param p point to free
1388 */
1389void
1390GNUNET_CRYPTO_ecc_free (gcry_mpi_point_t p);
1391
1392
1393/**
1314 * Release precalculated values. 1394 * Release precalculated values.
1315 * 1395 *
1316 * @param dlc dlog context 1396 * @param dlc dlog context