public ECVKO() { super("ECGOST3410", new ECVKOAgreement(new GOST3411Digest()), null); } }
public void init( CipherParameters key) { ParametersWithUKM p = (ParametersWithUKM)key; this.key = (ECPrivateKeyParameters)p.getParameters(); this.ukm = toInteger(p.getUKM()); }
private void initFromKey(Key key, AlgorithmParameterSpec parameterSpec) throws InvalidKeyException { { if (!(key instanceof PrivateKey)) { throw new InvalidKeyException(kaAlgorithm + " key agreement requires " + getSimpleName(ECPrivateKey.class) + " for initialisation"); } ECPrivateKeyParameters privKey = (ECPrivateKeyParameters)ECUtil.generatePrivateKeyParameter((PrivateKey)key); this.parameters = privKey.getParameters(); ukmParameters = (parameterSpec instanceof UserKeyingMaterialSpec) ? ((UserKeyingMaterialSpec)parameterSpec).getUserKeyingMaterial() : null; agreement.init(new ParametersWithUKM(privKey, ukmParameters)); } }
result = agreement.calculateAgreement(pubKey);
public byte[] calculateAgreement( CipherParameters pubKey) { ECPublicKeyParameters pub = (ECPublicKeyParameters)pubKey; ECDomainParameters params = pub.getParameters(); if (!params.equals(key.getParameters())) { throw new IllegalStateException("ECVKO public key has wrong domain parameters"); } BigInteger hd = params.getH().multiply(ukm).multiply(key.getD()).mod(params.getN()); ECPoint P = pub.getQ().multiply(hd).normalize(); if (P.isInfinity()) { throw new IllegalStateException("Infinity is not a valid agreement value for ECVKO"); } return fromPoint(P.normalize()); }
private void initFromKey(Key key, AlgorithmParameterSpec parameterSpec) throws InvalidKeyException { { if (!(key instanceof PrivateKey)) { throw new InvalidKeyException(kaAlgorithm + " key agreement requires " + getSimpleName(ECPrivateKey.class) + " for initialisation"); } ECPrivateKeyParameters privKey = (ECPrivateKeyParameters)ECUtil.generatePrivateKeyParameter((PrivateKey)key); this.parameters = privKey.getParameters(); ukmParameters = (parameterSpec instanceof UserKeyingMaterialSpec) ? ((UserKeyingMaterialSpec)parameterSpec).getUserKeyingMaterial() : null; agreement.init(new ParametersWithUKM(privKey, ukmParameters)); } }
result = agreement.calculateAgreement(pubKey);
public ECVKO256() { super("ECGOST3410-2012-256", new ECVKOAgreement(new GOST3411_2012_256Digest()), null); } }
public ECVKO512() { super("ECGOST3410-2012-512", new ECVKOAgreement(new GOST3411_2012_512Digest()), null); } }