diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-05-13 16:19:10 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-05-13 16:19:10 +0000 |
commit | 55d612a4f2b68911b472d10bb7efd50d8740fe6e (patch) | |
tree | 95adabb8bee4032937a6ab9f19ec758896caf94f /src/util/crypto_ecc.c | |
parent | 4725d59b468f1f30ba2910992333ca157682ce29 (diff) | |
download | gnunet-55d612a4f2b68911b472d10bb7efd50d8740fe6e.tar.gz gnunet-55d612a4f2b68911b472d10bb7efd50d8740fe6e.zip |
towards using EdDSA-ECDHE instead of ECDSA-ECDHE combined cryptosystem (API only)
Diffstat (limited to 'src/util/crypto_ecc.c')
-rw-r--r-- | src/util/crypto_ecc.c | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c index 429d2bf4b..c3a60e841 100644 --- a/src/util/crypto_ecc.c +++ b/src/util/crypto_ecc.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2012, 2013 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2012, 2013, 2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -1398,7 +1398,9 @@ GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1398 | GNUNET_assert (0 == | 1398 | GNUNET_assert (0 == |
1399 | gcry_mpi_print (GCRYMPI_FMT_STD, xbuf, rsize, &rsize, | 1399 | gcry_mpi_print (GCRYMPI_FMT_STD, xbuf, rsize, &rsize, |
1400 | result_x)); | 1400 | result_x)); |
1401 | GNUNET_CRYPTO_hash (xbuf, rsize, key_material); | 1401 | GNUNET_CRYPTO_hash (xbuf, |
1402 | rsize, | ||
1403 | key_material); | ||
1402 | gcry_mpi_release (result_x); | 1404 | gcry_mpi_release (result_x); |
1403 | return GNUNET_OK; | 1405 | return GNUNET_OK; |
1404 | } | 1406 | } |
@@ -1542,46 +1544,41 @@ GNUNET_CRYPTO_ecdsa_public_key_derive (const struct GNUNET_CRYPTO_EcdsaPublicKey | |||
1542 | 1544 | ||
1543 | /** | 1545 | /** |
1544 | * @ingroup crypto | 1546 | * @ingroup crypto |
1545 | * Convert ECDSA public key to ECDHE public key. | 1547 | * Derive key material from a ECDH public key and a private EdDSA key. |
1546 | * Please be very careful when using this function, as mixing | 1548 | * Dual to #GNUNET_CRRYPTO_ecdh_eddsa. |
1547 | * cryptographic primitives is not always healthy. | ||
1548 | * | 1549 | * |
1549 | * @param ecdsa ecdsa public key | 1550 | * @param priv private key from EdDSA to use for the ECDH (x) |
1550 | * @param ecdhe[OUT] ecdhe public key | 1551 | * @param pub public key to use for the ECDH (yG) |
1552 | * @param key_material where to write the key material H(h(x)yG) | ||
1553 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1551 | */ | 1554 | */ |
1552 | void | 1555 | int |
1553 | GNUNET_CRYPTO_ecdsa_public_to_ecdhe (const struct GNUNET_CRYPTO_EcdsaPublicKey *ecdsa, | 1556 | GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
1554 | struct GNUNET_CRYPTO_EcdhePublicKey *ecdhe) | 1557 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1558 | struct GNUNET_HashCode *key_material) | ||
1555 | { | 1559 | { |
1556 | GNUNET_assert (sizeof (struct GNUNET_CRYPTO_EcdhePublicKey) == | 1560 | return GNUNET_SYSERR; |
1557 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | ||
1558 | memcpy (ecdhe, | ||
1559 | ecdsa, | ||
1560 | sizeof (struct GNUNET_CRYPTO_EcdhePublicKey)); | ||
1561 | } | 1561 | } |
1562 | 1562 | ||
1563 | 1563 | ||
1564 | |||
1565 | /** | 1564 | /** |
1566 | * @ingroup crypto | 1565 | * @ingroup crypto |
1567 | * Convert ECDSA private key to ECDHE private key. | 1566 | * Derive key material from a EdDSA public key and a private ECDH key. |
1568 | * Please be very careful when using this function, as mixing | 1567 | * Dual to #GNUNET_CRRYPTO_eddsa_ecdh. |
1569 | * cryptographic primitives is not always healthy. | ||
1570 | * | 1568 | * |
1571 | * @param ecdsa ecdsa private key | 1569 | * @param priv private key to use for the ECDH (y) |
1572 | * @param ecdhe[OUT] ecdhe private key | 1570 | * @param pub public key from EdDSA to use for the ECDH (X=h(x)G) |
1571 | * @param key_material where to write the key material H(yX)=H(h(x)yG) | ||
1572 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1573 | */ | 1573 | */ |
1574 | void | 1574 | int |
1575 | GNUNET_CRYPTO_ecdsa_private_to_ecdhe (const struct GNUNET_CRYPTO_EcdsaPrivateKey *ecdsa, | 1575 | GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1576 | struct GNUNET_CRYPTO_EcdhePrivateKey *ecdhe) | 1576 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, |
1577 | struct GNUNET_HashCode *key_material) | ||
1577 | { | 1578 | { |
1578 | GNUNET_assert (sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey) == | 1579 | return GNUNET_SYSERR; |
1579 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)); | ||
1580 | memcpy (ecdhe, | ||
1581 | ecdsa, | ||
1582 | sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey)); | ||
1583 | |||
1584 | } | 1580 | } |
1585 | 1581 | ||
1586 | 1582 | ||
1583 | |||
1587 | /* end of crypto_ecc.c */ | 1584 | /* end of crypto_ecc.c */ |