I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit dfbe3c4e authored by zzz's avatar zzz
Browse files

signing key type check

parent b8170a54
No related branches found
No related tags found
No related merge requests found
...@@ -159,6 +159,7 @@ public class KeyGenerator { ...@@ -159,6 +159,7 @@ public class KeyGenerator {
/** Convert a PrivateKey to its corresponding PublicKey /** Convert a PrivateKey to its corresponding PublicKey
* @param priv PrivateKey object * @param priv PrivateKey object
* @return the corresponding PublicKey object * @return the corresponding PublicKey object
* @throws IllegalArgumentException on bad key
*/ */
public static PublicKey getPublicKey(PrivateKey priv) { public static PublicKey getPublicKey(PrivateKey priv) {
BigInteger a = new NativeBigInteger(1, priv.toByteArray()); BigInteger a = new NativeBigInteger(1, priv.toByteArray());
...@@ -265,8 +266,11 @@ public class KeyGenerator { ...@@ -265,8 +266,11 @@ public class KeyGenerator {
* *
* @param priv a SigningPrivateKey object * @param priv a SigningPrivateKey object
* @return a SigningPublicKey object * @return a SigningPublicKey object
* @throws IllegalArgumentException on bad key
*/ */
public static SigningPublicKey getSigningPublicKey(SigningPrivateKey priv) { public static SigningPublicKey getSigningPublicKey(SigningPrivateKey priv) {
if (priv.getType() != SigType.DSA_SHA1)
throw new IllegalArgumentException();
BigInteger x = new NativeBigInteger(1, priv.toByteArray()); BigInteger x = new NativeBigInteger(1, priv.toByteArray());
BigInteger y = CryptoConstants.dsag.modPow(x, CryptoConstants.dsap); BigInteger y = CryptoConstants.dsag.modPow(x, CryptoConstants.dsap);
SigningPublicKey pub = new SigningPublicKey(); SigningPublicKey pub = new SigningPublicKey();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment