aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-09 15:51:57 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-09 15:51:57 +0000
commitefd634ccf636b870b2dbd79f8969f8999c5573fa (patch)
tree4492353a28bf7add22f9ea7a42233a6bd679ca44 /src/include
parent8215376b2d1b4a3d95a0cf1ba474cf4be437c1b0 (diff)
downloadgnunet-efd634ccf636b870b2dbd79f8969f8999c5573fa.tar.gz
gnunet-efd634ccf636b870b2dbd79f8969f8999c5573fa.zip
adding support for blind signatures (modernized version of Taler logic, with variable key length)
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_crypto_lib.h257
1 files changed, 257 insertions, 0 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 0023c0e52..dbfcf8ea2 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -1392,6 +1392,263 @@ GNUNET_CRYPTO_paillier_hom_add (const struct GNUNET_CRYPTO_PaillierPublicKey *pu
1392int 1392int
1393GNUNET_CRYPTO_paillier_hom_get_remaining (const struct GNUNET_CRYPTO_PaillierCiphertext *c); 1393GNUNET_CRYPTO_paillier_hom_get_remaining (const struct GNUNET_CRYPTO_PaillierCiphertext *c);
1394 1394
1395
1396/* ********* Chaum-style RSA-based blind signatures ******************* */
1397
1398
1399
1400
1401/**
1402 * The private information of an RSA key pair.
1403 */
1404struct GNUNET_CRYPTO_rsa_PrivateKey;
1405
1406/**
1407 * The public information of an RSA key pair.
1408 */
1409struct GNUNET_CRYPTO_rsa_PublicKey;
1410
1411/**
1412 * Key used to blind a message
1413 */
1414struct GNUNET_CRYPTO_rsa_BlindingKey;
1415
1416/**
1417 * @brief an RSA signature
1418 */
1419struct GNUNET_CRYPTO_rsa_Signature;
1420
1421
1422/**
1423 * Create a new private key. Caller must free return value.
1424 *
1425 * @param len length of the key in bits (i.e. 2048)
1426 * @return fresh private key
1427 */
1428struct GNUNET_CRYPTO_rsa_PrivateKey *
1429GNUNET_CRYPTO_rsa_private_key_create (unsigned int len);
1430
1431
1432/**
1433 * Free memory occupied by the private key.
1434 *
1435 * @param key pointer to the memory to free
1436 */
1437void
1438GNUNET_CRYPTO_rsa_private_key_free (struct GNUNET_CRYPTO_rsa_PrivateKey *key);
1439
1440
1441/**
1442 * Encode the private key in a format suitable for
1443 * storing it into a file.
1444 *
1445 * @param key the private key
1446 * @param[out] buffer set to a buffer with the encoded key
1447 * @return size of memory allocatedin @a buffer
1448 */
1449size_t
1450GNUNET_CRYPTO_rsa_private_key_encode (const struct GNUNET_CRYPTO_rsa_PrivateKey *key,
1451 char **buffer);
1452
1453
1454/**
1455 * Decode the private key from the data-format back
1456 * to the "normal", internal format.
1457 *
1458 * @param buf the buffer where the private key data is stored
1459 * @param len the length of the data in @a buf
1460 * @return NULL on error
1461 */
1462struct GNUNET_CRYPTO_rsa_PrivateKey *
1463GNUNET_CRYPTO_rsa_private_key_decode (const char *buf,
1464 size_t len);
1465
1466
1467/**
1468 * Extract the public key of the given private key.
1469 *
1470 * @param priv the private key
1471 * @retur NULL on error, otherwise the public key
1472 */
1473struct GNUNET_CRYPTO_rsa_PublicKey *
1474GNUNET_CRYPTO_rsa_private_key_get_public (const struct GNUNET_CRYPTO_rsa_PrivateKey *priv);
1475
1476
1477/**
1478 * Free memory occupied by the public key.
1479 *
1480 * @param key pointer to the memory to free
1481 */
1482void
1483GNUNET_CRYPTO_rsa_public_key_free (struct GNUNET_CRYPTO_rsa_PublicKey *key);
1484
1485
1486/**
1487 * Encode the public key in a format suitable for
1488 * storing it into a file.
1489 *
1490 * @param key the private key
1491 * @param[out] buffer set to a buffer with the encoded key
1492 * @return size of memory allocated in @a buffer
1493 */
1494size_t
1495GNUNET_CRYPTO_rsa_public_key_encode (const struct GNUNET_CRYPTO_rsa_PublicKey *key,
1496 char **buffer);
1497
1498
1499/**
1500 * Decode the public key from the data-format back
1501 * to the "normal", internal format.
1502 *
1503 * @param buf the buffer where the public key data is stored
1504 * @param len the length of the data in @a buf
1505 * @return NULL on error
1506 */
1507struct GNUNET_CRYPTO_rsa_PublicKey *
1508GNUNET_CRYPTO_rsa_public_key_decode (const char *buf,
1509 size_t len);
1510
1511
1512/**
1513 * Create a blinding key
1514 *
1515 * @param len length of the key in bits (i.e. 2048)
1516 * @return the newly created blinding key
1517 */
1518struct GNUNET_CRYPTO_rsa_BlindingKey *
1519GNUNET_CRYPTO_rsa_blinding_key_create (unsigned int len);
1520
1521
1522/**
1523 * Destroy a blinding key
1524 *
1525 * @param bkey the blinding key to destroy
1526 */
1527void
1528GNUNET_CRYPTO_rsa_blinding_key_free (struct GNUNET_CRYPTO_rsa_BlindingKey *bkey);
1529
1530
1531/**
1532 * Encode the blinding key in a format suitable for
1533 * storing it into a file.
1534 *
1535 * @param bkey the blinding key
1536 * @param[out] buffer set to a buffer with the encoded key
1537 * @return size of memory allocated in @a buffer
1538 */
1539size_t
1540GNUNET_CRYPTO_rsa_blinding_key_encode (const struct GNUNET_CRYPTO_rsa_BlindingKey *bkey,
1541 char **buffer);
1542
1543
1544/**
1545 * Decode the blinding key from the data-format back
1546 * to the "normal", internal format.
1547 *
1548 * @param buf the buffer where the public key data is stored
1549 * @param len the length of the data in @a buf
1550 * @return NULL on error
1551 */
1552struct GNUNET_CRYPTO_rsa_BlindingKey *
1553GNUNET_CRYPTO_rsa_blinding_key_decode (const char *buf,
1554 size_t len);
1555
1556
1557/**
1558 * Blinds the given message with the given blinding key
1559 *
1560 * @param hash hash of the message to sign
1561 * @param bkey the blinding key
1562 * @param pkey the public key of the signer
1563 * @param[out] buffer set to a buffer with the blinded message to be signed
1564 * @return number of bytes stored in @a buffer
1565 */
1566size_t
1567GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
1568 struct GNUNET_CRYPTO_rsa_BlindingKey *bkey,
1569 struct GNUNET_CRYPTO_rsa_PublicKey *pkey,
1570 char **buffer);
1571
1572
1573/**
1574 * Sign the given message.
1575 *
1576 * @param key private key to use for the signing
1577 * @param msg the (blinded) message to sign
1578 * @param msg_len number of bytes in @a msg to sign
1579 * @return NULL on error, signature on success
1580 */
1581struct GNUNET_CRYPTO_rsa_Signature *
1582GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_rsa_PrivateKey *key,
1583 const void *msg,
1584 size_t msg_len);
1585
1586
1587/**
1588 * Free memory occupied by signature.
1589 *
1590 * @param sig memory to freee
1591 */
1592void
1593GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_rsa_Signature *sig);
1594
1595
1596/**
1597 * Encode the signature key in a format suitable for
1598 * storing it into a file.
1599 *
1600 * @param sig the signature
1601 * @param[out] buffer set to a buffer with the encoded key
1602 * @return size of memory allocated in @a buffer
1603 */
1604size_t
1605GNUNET_CRYPTO_rsa_signature_encode (const struct GNUNET_CRYPTO_rsa_Signature *sig,
1606 char **buffer);
1607
1608
1609/**
1610 * Decode the public key from the data-format back
1611 * to the "normal", internal format.
1612 *
1613 * @param buf the buffer where the public key data is stored
1614 * @param len the length of the data in @a buf
1615 * @return NULL on error
1616 */
1617struct GNUNET_CRYPTO_rsa_Signature *
1618GNUNET_CRYPTO_rsa_signature_decode (const char *buf,
1619 size_t len);
1620
1621
1622/**
1623 * Unblind a signature made on blinding signature purpose. The signature
1624 * purpose should have been generated with #GNUNET_CRYPTO_rsa_sign() using
1625 * a message that was generated with #GNUNET_CRYPTO_rsa_blind().
1626 *
1627 * @param sig the signature made on the blinded signature purpose
1628 * @param bkey the blinding key used to blind the signature purpose
1629 * @param pkey the public key of the signer
1630 * @return unblinded signature on success, NULL on error
1631 */
1632struct GNUNET_CRYPTO_rsa_Signature *
1633GNUNET_CRYPTO_rsa_unblind (struct GNUNET_CRYPTO_rsa_Signature *sig,
1634 struct GNUNET_CRYPTO_rsa_BlindingKey *bkey,
1635 struct GNUNET_CRYPTO_rsa_PublicKey *pkey);
1636
1637
1638/**
1639 * Verify signature with the given hash.
1640 *
1641 * @param hash the message to verify to match the @a sig
1642 * @param sig signature that is being validated
1643 * @param public_key public key of the signer
1644 * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid
1645 */
1646int
1647GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash,
1648 const struct GNUNET_CRYPTO_rsa_Signature *sig,
1649 const struct GNUNET_CRYPTO_rsa_PublicKey *public_key);
1650
1651
1395#if 0 /* keep Emacsens' auto-indent happy */ 1652#if 0 /* keep Emacsens' auto-indent happy */
1396{ 1653{
1397#endif 1654#endif