BCGOST3410PrivateKey( GOST3410PrivateKeyParameters params, GOST3410ParameterSpec spec) { this.x = params.getX(); this.gost3410Spec = spec; if (spec == null) { throw new IllegalArgumentException("spec is null"); } }
public AsymmetricCipherKeyPair generateKeyPair() { BigInteger p, q, a, x, y; GOST3410Parameters GOST3410Params = param.getParameters(); SecureRandom random = param.getRandom(); q = GOST3410Params.getQ(); p = GOST3410Params.getP(); a = GOST3410Params.getA(); do { x = new BigInteger(256, random); } while (x.equals(ZERO) || x.compareTo(q) >= 0); // // calculate the public key. // y = a.modPow(x, p); return new AsymmetricCipherKeyPair( new GOST3410PublicKeyParameters(y, GOST3410Params), new GOST3410PrivateKeyParameters(x, GOST3410Params)); } }
new GOST3410PrivateKeyParameters(x, GOST3410Params));
static public AsymmetricKeyParameter generatePrivateKeyParameter( PrivateKey key) throws InvalidKeyException { if (key instanceof GOST3410PrivateKey) { GOST3410PrivateKey k = (GOST3410PrivateKey)key; GOST3410PublicKeyParameterSetSpec p = k.getParameters().getPublicKeyParameters(); return new GOST3410PrivateKeyParameters(k.getX(), new GOST3410Parameters(p.getP(), p.getQ(), p.getA())); } throw new InvalidKeyException("can't identify GOST3410 private key."); } }
BCGOST3410PrivateKey( GOST3410PrivateKeyParameters params, GOST3410ParameterSpec spec) { this.x = params.getX(); this.gost3410Spec = spec; if (spec == null) { throw new IllegalArgumentException("spec is null"); } }
static public AsymmetricKeyParameter generatePrivateKeyParameter( PrivateKey key) throws InvalidKeyException { if (key instanceof GOST3410PrivateKey) { GOST3410PrivateKey k = (GOST3410PrivateKey)key; GOST3410PublicKeyParameterSetSpec p = k.getParameters().getPublicKeyParameters(); return new GOST3410PrivateKeyParameters(k.getX(), new GOST3410Parameters(p.getP(), p.getQ(), p.getA())); } throw new InvalidKeyException("can't identify GOST3410 private key."); } }
add(((GOST3410PrivateKeyParameters)key).getX().multiply(r)). mod(params.getQ());
add(((GOST3410PrivateKeyParameters)key).getX().multiply(r)). mod(params.getQ());