mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-23 17:36:37 +02:00
use GOST 34.11-2012 with GOST 34.10
This commit is contained in:
parent
fcbf81a3d4
commit
726828a487
3 changed files with 11 additions and 21 deletions
|
@ -102,7 +102,7 @@ namespace data
|
||||||
memcpy (m_StandardIdentity.signingKey + padding, signingKey, i2p::crypto::EDDSA25519_PUBLIC_KEY_LENGTH);
|
memcpy (m_StandardIdentity.signingKey + padding, signingKey, i2p::crypto::EDDSA25519_PUBLIC_KEY_LENGTH);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SIGNING_KEY_TYPE_GOSTR3410_2001_CRYPTO_PRO_A_GOSTR3411:
|
case SIGNING_KEY_TYPE_GOSTR3410_2001_CRYPTO_PRO_A_SHA256:
|
||||||
case SIGNING_KEY_TYPE_GOSTR3410_2012_TC26_A_256_GOSTR3411:
|
case SIGNING_KEY_TYPE_GOSTR3410_2012_TC26_A_256_GOSTR3411:
|
||||||
{
|
{
|
||||||
// 256
|
// 256
|
||||||
|
@ -386,7 +386,7 @@ namespace data
|
||||||
UpdateVerifier (new i2p::crypto::EDDSA25519Verifier (m_StandardIdentity.signingKey + padding));
|
UpdateVerifier (new i2p::crypto::EDDSA25519Verifier (m_StandardIdentity.signingKey + padding));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SIGNING_KEY_TYPE_GOSTR3410_2001_CRYPTO_PRO_A_GOSTR3411:
|
case SIGNING_KEY_TYPE_GOSTR3410_2001_CRYPTO_PRO_A_SHA256 :
|
||||||
{
|
{
|
||||||
size_t padding = 128 - i2p::crypto::GOSTR3410_256_PUBLIC_KEY_LENGTH; // 64 = 128 - 64
|
size_t padding = 128 - i2p::crypto::GOSTR3410_256_PUBLIC_KEY_LENGTH; // 64 = 128 - 64
|
||||||
UpdateVerifier (new i2p::crypto::GOSTR3410_2001_Verifier (i2p::crypto::eGOSTR3410CryptoProA, m_StandardIdentity.signingKey + padding));
|
UpdateVerifier (new i2p::crypto::GOSTR3410_2001_Verifier (i2p::crypto::eGOSTR3410CryptoProA, m_StandardIdentity.signingKey + padding));
|
||||||
|
@ -545,7 +545,7 @@ namespace data
|
||||||
case SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519:
|
case SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519:
|
||||||
m_Signer.reset (new i2p::crypto::EDDSA25519Signer (m_SigningPrivateKey, m_Public->GetStandardIdentity ().certificate - i2p::crypto::EDDSA25519_PUBLIC_KEY_LENGTH));
|
m_Signer.reset (new i2p::crypto::EDDSA25519Signer (m_SigningPrivateKey, m_Public->GetStandardIdentity ().certificate - i2p::crypto::EDDSA25519_PUBLIC_KEY_LENGTH));
|
||||||
break;
|
break;
|
||||||
case SIGNING_KEY_TYPE_GOSTR3410_2001_CRYPTO_PRO_A_GOSTR3411:
|
case SIGNING_KEY_TYPE_GOSTR3410_2001_CRYPTO_PRO_A_SHA256:
|
||||||
m_Signer.reset (new i2p::crypto::GOSTR3410_2001_Signer (i2p::crypto::eGOSTR3410CryptoProA, m_SigningPrivateKey));
|
m_Signer.reset (new i2p::crypto::GOSTR3410_2001_Signer (i2p::crypto::eGOSTR3410CryptoProA, m_SigningPrivateKey));
|
||||||
break;
|
break;
|
||||||
case SIGNING_KEY_TYPE_GOSTR3410_2012_TC26_A_256_GOSTR3411:
|
case SIGNING_KEY_TYPE_GOSTR3410_2012_TC26_A_256_GOSTR3411:
|
||||||
|
@ -589,7 +589,7 @@ namespace data
|
||||||
case SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519:
|
case SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519:
|
||||||
i2p::crypto::CreateEDDSA25519RandomKeys (keys.m_SigningPrivateKey, signingPublicKey);
|
i2p::crypto::CreateEDDSA25519RandomKeys (keys.m_SigningPrivateKey, signingPublicKey);
|
||||||
break;
|
break;
|
||||||
case SIGNING_KEY_TYPE_GOSTR3410_2001_CRYPTO_PRO_A_GOSTR3411:
|
case SIGNING_KEY_TYPE_GOSTR3410_2001_CRYPTO_PRO_A_SHA256:
|
||||||
i2p::crypto::CreateGOSTR3410RandomKeys (i2p::crypto::eGOSTR3410CryptoProA, keys.m_SigningPrivateKey, signingPublicKey);
|
i2p::crypto::CreateGOSTR3410RandomKeys (i2p::crypto::eGOSTR3410CryptoProA, keys.m_SigningPrivateKey, signingPublicKey);
|
||||||
break;
|
break;
|
||||||
case SIGNING_KEY_TYPE_GOSTR3410_2012_TC26_A_256_GOSTR3411:
|
case SIGNING_KEY_TYPE_GOSTR3410_2012_TC26_A_256_GOSTR3411:
|
||||||
|
|
|
@ -61,9 +61,9 @@ namespace data
|
||||||
const uint16_t SIGNING_KEY_TYPE_RSA_SHA512_4096 = 6;
|
const uint16_t SIGNING_KEY_TYPE_RSA_SHA512_4096 = 6;
|
||||||
const uint16_t SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519 = 7;
|
const uint16_t SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519 = 7;
|
||||||
// following signature type should never appear in netid=2
|
// following signature type should never appear in netid=2
|
||||||
const uint16_t SIGNING_KEY_TYPE_GOSTR3410_2001_CRYPTO_PRO_A_GOSTR3411 = 65280; // approved by FSB
|
const uint16_t SIGNING_KEY_TYPE_GOSTR3410_2001_CRYPTO_PRO_A_SHA256 = 65280;
|
||||||
const uint16_t SIGNING_KEY_TYPE_GOSTR3410_2012_TC26_A_256_GOSTR3411 = 65281;
|
const uint16_t SIGNING_KEY_TYPE_GOSTR3410_2012_TC26_A_256_GOSTR3411 = 65281;
|
||||||
const uint16_t SIGNING_KEY_TYPE_GOSTR3410_2012_TC26_A_512_GOSTR3411 = 65282;
|
const uint16_t SIGNING_KEY_TYPE_GOSTR3410_2012_TC26_A_512_GOSTR3411 = 65282; // approved by FSB
|
||||||
|
|
||||||
typedef uint16_t SigningKeyType;
|
typedef uint16_t SigningKeyType;
|
||||||
typedef uint16_t CryptoKeyType;
|
typedef uint16_t CryptoKeyType;
|
||||||
|
|
20
Signature.h
20
Signature.h
|
@ -444,22 +444,12 @@ namespace crypto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ГОСТ Р 34.11
|
// ГОСТ Р 34.11
|
||||||
struct GOSTR3411_2001_Hash
|
|
||||||
{
|
|
||||||
static void CalculateHash (const uint8_t * buf, size_t len, uint8_t * digest)
|
|
||||||
{
|
|
||||||
SHA256 (buf, len, digest); // TODO: implement GOST R 34.11 - 2001
|
|
||||||
}
|
|
||||||
|
|
||||||
enum { hashLen = 32 };
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GOSTR3411_2012_256_Hash
|
struct GOSTR3411_2012_256_Hash
|
||||||
{
|
{
|
||||||
static void CalculateHash (const uint8_t * buf, size_t len, uint8_t * digest)
|
static void CalculateHash (const uint8_t * buf, size_t len, uint8_t * digest)
|
||||||
{
|
{
|
||||||
SHA256 (buf, len, digest); // TODO: implement GOST R 34.11 - 2012
|
GOSTR3411_2012_256 (buf, len, digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { hashLen = 32 };
|
enum { hashLen = 32 };
|
||||||
|
@ -469,7 +459,7 @@ namespace crypto
|
||||||
{
|
{
|
||||||
static void CalculateHash (const uint8_t * buf, size_t len, uint8_t * digest)
|
static void CalculateHash (const uint8_t * buf, size_t len, uint8_t * digest)
|
||||||
{
|
{
|
||||||
SHA512 (buf, len, digest); // TODO: implement GOST R 34.11 - 2012
|
GOSTR3411_2012_512 (buf, len, digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { hashLen = 64 };
|
enum { hashLen = 64 };
|
||||||
|
@ -566,8 +556,8 @@ namespace crypto
|
||||||
BN_free (x); BN_free (y);
|
BN_free (x); BN_free (y);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef GOSTR3410Verifier<GOSTR3411_2001_Hash> GOSTR3410_2001_Verifier;
|
typedef GOSTR3410Verifier<SHA256Hash> GOSTR3410_2001_Verifier;
|
||||||
typedef GOSTR3410Signer<GOSTR3411_2001_Hash> GOSTR3410_2001_Signer;
|
typedef GOSTR3410Signer<SHA256Hash> GOSTR3410_2001_Signer;
|
||||||
typedef GOSTR3410Verifier<GOSTR3411_2012_256_Hash> GOSTR3410_2012_256_Verifier;
|
typedef GOSTR3410Verifier<GOSTR3411_2012_256_Hash> GOSTR3410_2012_256_Verifier;
|
||||||
typedef GOSTR3410Signer<GOSTR3411_2012_256_Hash> GOSTR3410_2012_256_Signer;
|
typedef GOSTR3410Signer<GOSTR3411_2012_256_Hash> GOSTR3410_2012_256_Signer;
|
||||||
typedef GOSTR3410Verifier<GOSTR3411_2012_512_Hash> GOSTR3410_2012_512_Verifier;
|
typedef GOSTR3410Verifier<GOSTR3411_2012_512_Hash> GOSTR3410_2012_512_Verifier;
|
||||||
|
|
Loading…
Add table
Reference in a new issue