public class DiffieHellmanSession extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ALGORITHM |
static long |
DEFAULT_GENERATOR |
static String |
DEFAULT_GENERATOR_BASE64 |
static String |
DEFAULT_MODULUS_BASE64 |
static String |
DEFAULT_MODULUS_HEX |
static String |
H_ALGORITHM_SHA1 |
static String |
H_ALGORITHM_SHA256 |
Modifier and Type | Method and Description |
---|---|
static DiffieHellmanSession |
create(AssociationSessionType type,
DHParameterSpec dhParameterSpec) |
static DiffieHellmanSession |
create(AssociationSessionType type,
String modulusBase64,
String generatorBase64) |
byte[] |
decryptMacKey(String encMacKeyBase64,
String serverPublicKeyBase64)
Decrypts the association AMC key.
|
String |
encryptMacKey(byte[] macKey,
String consumerPublicKeyBase64)
Encrypts the association MAC key.
|
protected static KeyPair |
generateKeyPair(DHParameterSpec dhSpec) |
static DHParameterSpec |
generateRandomParameter(int primeSize,
int keySize) |
static DHParameterSpec |
getDefaultParameter() |
protected byte[] |
getDigestedZZ(String otherPublicKeyBase64) |
String |
getGenerator()
Gets the generator for the Diffie-Hellman key echange.
|
String |
getModulus()
Gets the modulus for the Diffie-Hellman key echange.
|
protected DHPrivateKey |
getPrivateKey() |
String |
getPublicKey()
Get the Diffie-Hellman public key.
|
AssociationSessionType |
getType() |
static boolean |
isDhSha1Supported() |
static boolean |
isDhSha256Supported() |
static boolean |
isDhShaSupported(String shaAlgorithm) |
static boolean |
isDhSupported(AssociationSessionType type) |
protected static String |
publicKeyToString(DHPublicKey publicKey) |
protected DHPublicKey |
stringToPublicKey(String publicKeyBase64) |
String |
toString() |
public static final String DEFAULT_MODULUS_HEX
public static final String DEFAULT_MODULUS_BASE64
public static final long DEFAULT_GENERATOR
public static final String DEFAULT_GENERATOR_BASE64
public static final String ALGORITHM
public static final String H_ALGORITHM_SHA1
public static final String H_ALGORITHM_SHA256
public static DiffieHellmanSession create(AssociationSessionType type, String modulusBase64, String generatorBase64) throws AssociationException
AssociationException
public static DiffieHellmanSession create(AssociationSessionType type, DHParameterSpec dhParameterSpec) throws AssociationException
AssociationException
public static DHParameterSpec getDefaultParameter()
public static DHParameterSpec generateRandomParameter(int primeSize, int keySize)
protected static KeyPair generateKeyPair(DHParameterSpec dhSpec)
public AssociationSessionType getType()
public String getModulus()
base64(btwoc(p))
public String getGenerator()
base64(btwoc(g))
public String getPublicKey()
base64(btwoc(g ^ x mod p))
protected DHPrivateKey getPrivateKey()
public String encryptMacKey(byte[] macKey, String consumerPublicKeyBase64) throws AssociationException
macKey
- The MAC key in binary format.consumerPublicKeyBase64
- The base 64 encoding of the consumer
Diffie-Hellman public key. This is the
value passed in the
openid.dh_consumer_public
association request parameter.base64(H(btwoc(g ^ (xa * xb) mod p)) XOR MAC)
AssociationException
- if the lengths of the mac key and digest
of Diffie-Hellman shared secred do not
match.public byte[] decryptMacKey(String encMacKeyBase64, String serverPublicKeyBase64) throws AssociationException
encMacKeyBase64
- The base 64 encoded two's-complement
representation of the encrypted mac key:
base64(H(btwoc(g ^ (xa * xb) mod p)) XOR MAC)
.
This is the value passed in the
openid.enc_mac_key association
response parameter.serverPublicKeyBase64
- The base 64 encoding of the server
Diffie-Hellman public key. This is the
value passed in the
openid.dh_server_public
association response parameter.AssociationException
- if the lengths of the encrypted mac key
and digest of Diffie-Hellman shared
secret do not match.protected static String publicKeyToString(DHPublicKey publicKey)
protected DHPublicKey stringToPublicKey(String publicKeyBase64)
protected byte[] getDigestedZZ(String otherPublicKeyBase64)
public static boolean isDhSupported(AssociationSessionType type)
public static boolean isDhShaSupported(String shaAlgorithm)
public static boolean isDhSha1Supported()
public static boolean isDhSha256Supported()
Copyright © 2019 Sxip. All rights reserved.