Browse Source

EdDSA signature type added

pull/178/head
orignal 10 years ago
parent
commit
454f2dabbd
  1. 13
      Identity.cpp
  2. 1
      Identity.h
  3. 5
      Signature.cpp
  4. 18
      Signature.h

13
Identity.cpp

@ -95,6 +95,13 @@ namespace data
memcpy (excessBuf, signingKey + 128, excessLen); memcpy (excessBuf, signingKey + 128, excessLen);
break; break;
} }
case SIGNING_KEY_TYPE_EDDSA_SHA512:
{
size_t padding = 128 - i2p::crypto::EDDSA_PUBLIC_KEY_LENGTH; // 96 = 128 - 32
i2p::context.GetRandomNumberGenerator ().GenerateBlock (m_StandardIdentity.signingKey, padding);
memcpy (m_StandardIdentity.signingKey + padding, signingKey, i2p::crypto::EDDSA_PUBLIC_KEY_LENGTH);
break;
}
default: default:
LogPrint ("Signing key type ", (int)type, " is not supported"); LogPrint ("Signing key type ", (int)type, " is not supported");
} }
@ -345,6 +352,12 @@ namespace data
m_Verifier = new i2p::crypto:: RSASHA5124096Verifier (signingKey); m_Verifier = new i2p::crypto:: RSASHA5124096Verifier (signingKey);
break; break;
} }
case SIGNING_KEY_TYPE_EDDSA_SHA512:
{
size_t padding = 128 - i2p::crypto::EDDSA_PUBLIC_KEY_LENGTH; // 96 = 128 - 32
m_Verifier = new i2p::crypto::EDDSAVerifier (m_StandardIdentity.signingKey + padding);
break;
}
default: default:
LogPrint ("Signing key type ", (int)keyType, " is not supported"); LogPrint ("Signing key type ", (int)keyType, " is not supported");
} }

1
Identity.h

@ -117,6 +117,7 @@ namespace data
const uint16_t SIGNING_KEY_TYPE_RSA_SHA256_2048 = 4; const uint16_t SIGNING_KEY_TYPE_RSA_SHA256_2048 = 4;
const uint16_t SIGNING_KEY_TYPE_RSA_SHA384_3072 = 5; const uint16_t SIGNING_KEY_TYPE_RSA_SHA384_3072 = 5;
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 = 7;
typedef uint16_t SigningKeyType; typedef uint16_t SigningKeyType;
typedef uint16_t CryptoKeyType; typedef uint16_t CryptoKeyType;

5
Signature.cpp

@ -78,6 +78,11 @@ namespace crypto
CryptoPP::Integer q, l, d, I; CryptoPP::Integer q, l, d, I;
}; };
bool EDDSAVerifier::Verify (const uint8_t * buf, size_t len, const uint8_t * signature) const
{
return true; // TODO:
}
} }
} }

18
Signature.h

@ -410,6 +410,24 @@ namespace crypto
{ {
} }
}; };
// EdDSA
const size_t EDDSA_PUBLIC_KEY_LENGTH = 32;
const size_t EDDSA_SIGNATURE_LENGTH = 64;
const size_t EDDSA_PRIVATE_KEY_LENGTH = 32;
class EDDSAVerifier: public Verifier
{
public:
EDDSAVerifier (const uint8_t * signingKey)
{
}
bool Verify (const uint8_t * buf, size_t len, const uint8_t * signature) const;
size_t GetPublicKeyLen () const { return EDDSA_PUBLIC_KEY_LENGTH; };
size_t GetSignatureLen () const { return EDDSA_SIGNATURE_LENGTH; };
};
} }
} }

Loading…
Cancel
Save