public static DiffieHellmanSession create(AssociationSessionType type, DHParameterSpec dhParameterSpec) throws AssociationException { DiffieHellmanSession dh = new DiffieHellmanSession(type, dhParameterSpec); if (DEBUG) _log.debug("Created DH session: " + dh); return dh; }
public static DiffieHellmanSession create(AssociationSessionType type, String modulusBase64, String generatorBase64) throws AssociationException { byte[] modulus = Base64.decodeBase64(modulusBase64.getBytes()); byte[] generator = Base64.decodeBase64(generatorBase64.getBytes()); BigInteger p = new BigInteger(modulus); BigInteger g = new BigInteger(generator); DHParameterSpec dhParameterSpec = new DHParameterSpec(p, g); return create(type, dhParameterSpec); }
throws AssociationException byte[] hzz = getDigestedZZ(consumerPublicKeyBase64);
protected byte[] getDigestedZZ(String otherPublicKeyBase64) { DHPublicKey dhPublicKey = stringToPublicKey(otherPublicKeyBase64); DHPrivateKey dhPrivateKey = getPrivateKey(); BigInteger xa = dhPrivateKey.getX(); BigInteger yb = dhPublicKey.getY(); BigInteger p = _dhParameterSpec.getP(); BigInteger zz = yb.modPow(xa, p); return _hDigest.digest(zz.toByteArray()); }
set("openid.dh_consumer_public", _dhSess.getPublicKey()); if (!DiffieHellmanSession.DEFAULT_GENERATOR_BASE64.equals(_dhSess.getGenerator()) || !DiffieHellmanSession.DEFAULT_MODULUS_BASE64.equals(_dhSess.getModulus())) set("openid.dh_gen", _dhSess.getGenerator()); set("openid.dh_modulus", _dhSess.getModulus());
DiffieHellmanSession dhSess = DiffieHellmanSession.create( type, assocReq.getDhModulus(), assocReq.getDhGen() ); setPublicKey(dhSess.getPublicKey()); setMacKeyEnc(dhSess.encryptMacKey( assoc.getMacKey().getEncoded(), assocReq.getDhPublicKey() ));
if (type.getHAlgorithm() != null) // DH session dhSess = DiffieHellmanSession.create(type, _dhParams); if (DiffieHellmanSession.isDhSupported(type) && Association.isHmacSupported(type.getAssociationType())) assocReq = AssociationRequest.createAssociationRequest(type, dhSess);
private DiffieHellmanSession(AssociationSessionType type, DHParameterSpec dhParameterSpec) throws AssociationException { _type = type; _dhParameterSpec = dhParameterSpec; _keyPair = generateKeyPair(dhParameterSpec); try { _hDigest = MessageDigest.getInstance(_type.getHAlgorithm()); } catch (NoSuchAlgorithmException e) { throw new AssociationException("Unsupported H algorithm: " + _type.getHAlgorithm(), e); } }
macKey = dhSess.decryptMacKey( getParameterValue("enc_mac_key"), getParameterValue("dh_server_public") );
set("openid.dh_consumer_public", _dhSess.getPublicKey()); if (!DiffieHellmanSession.DEFAULT_GENERATOR_BASE64.equals(_dhSess.getGenerator()) || !DiffieHellmanSession.DEFAULT_MODULUS_BASE64.equals(_dhSess.getModulus())) { set("openid.dh_gen", _dhSess.getGenerator()); set("openid.dh_modulus", _dhSess.getModulus());
DiffieHellmanSession dhSess = DiffieHellmanSession.create( type, assocReq.getDhModulus(), assocReq.getDhGen()); setPublicKey(dhSess.getPublicKey()); setMacKeyEnc(dhSess.encryptMacKey( assoc.getMacKey().getEncoded(), assocReq.getDhPublicKey()));
protected byte[] getDigestedZZ(String otherPublicKeyBase64) { DHPublicKey dhPublicKey = stringToPublicKey(otherPublicKeyBase64); DHPrivateKey dhPrivateKey = getPrivateKey(); BigInteger xa = dhPrivateKey.getX(); BigInteger yb = dhPublicKey.getY(); BigInteger p = _dhParameterSpec.getP(); BigInteger zz = yb.modPow(xa, p); return _hDigest.digest(zz.toByteArray()); }
if (type.getHAlgorithm() != null) // DH session dhSess = DiffieHellmanSession.create(type, _dhParams); if (DiffieHellmanSession.isDhSupported(type) && Association.isHmacSupported(type.getAssociationType())) assocReq = AssociationRequest.createAssociationRequest(type, dhSess);
private DiffieHellmanSession(AssociationSessionType type, DHParameterSpec dhParameterSpec) throws AssociationException { _type = type; _dhParameterSpec = dhParameterSpec; _keyPair = generateKeyPair(dhParameterSpec); try { _hDigest = MessageDigest.getInstance(_type.getHAlgorithm()); } catch (NoSuchAlgorithmException e) { throw new AssociationException("Unsupported H algorithm: " + _type.getHAlgorithm(), e); } }
macKey = dhSess.decryptMacKey( getParameterValue("enc_mac_key"), getParameterValue("dh_server_public") );
set("openid.dh_consumer_public", _dhSess.getPublicKey()); if (!DiffieHellmanSession.DEFAULT_GENERATOR_BASE64.equals(_dhSess.getGenerator()) || !DiffieHellmanSession.DEFAULT_MODULUS_BASE64.equals(_dhSess.getModulus())) set("openid.dh_gen", _dhSess.getGenerator()); set("openid.dh_modulus", _dhSess.getModulus());
DiffieHellmanSession dhSess = DiffieHellmanSession.create( type, assocReq.getDhModulus(), assocReq.getDhGen() ); setPublicKey(dhSess.getPublicKey()); setMacKeyEnc(dhSess.encryptMacKey( assoc.getMacKey().getEncoded(), assocReq.getDhPublicKey() ));
protected byte[] getDigestedZZ(String otherPublicKeyBase64) { DHPublicKey dhPublicKey = stringToPublicKey(otherPublicKeyBase64); DHPrivateKey dhPrivateKey = getPrivateKey(); BigInteger xa = dhPrivateKey.getX(); BigInteger yb = dhPublicKey.getY(); BigInteger p = _dhParameterSpec.getP(); BigInteger zz = yb.modPow(xa, p); return _hDigest.digest(zz.toByteArray()); } }
if (type.getHAlgorithm() != null) // DH session dhSess = DiffieHellmanSession.create(type, _dhParams); if (DiffieHellmanSession.isDhSupported(type) && Association.isHmacSupported(type.getAssociationType())) { assocReq = AssociationRequest.createAssociationRequest(type, dhSess);
byte[] hzz = getDigestedZZ(consumerPublicKeyBase64);