Tsukuyomi OpenID
0.2.0

jp.sourceforge.tsukuyomi.openid.association
クラス DiffieHellmanSession

java.lang.Object
  上位を拡張 jp.sourceforge.tsukuyomi.openid.association.DiffieHellmanSession

public class DiffieHellmanSession
extends Object

作成者:
Marius Scurtescu, Johnny Bufu

フィールドの概要
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
           
 
メソッドの概要
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()
           
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

フィールドの詳細

DEFAULT_MODULUS_HEX

public static final String DEFAULT_MODULUS_HEX
関連項目:
定数フィールド値

DEFAULT_MODULUS_BASE64

public static final String DEFAULT_MODULUS_BASE64
関連項目:
定数フィールド値

DEFAULT_GENERATOR

public static final long DEFAULT_GENERATOR
関連項目:
定数フィールド値

DEFAULT_GENERATOR_BASE64

public static final String DEFAULT_GENERATOR_BASE64
関連項目:
定数フィールド値

ALGORITHM

public static final String ALGORITHM
関連項目:
定数フィールド値

H_ALGORITHM_SHA1

public static final String H_ALGORITHM_SHA1
関連項目:
定数フィールド値

H_ALGORITHM_SHA256

public static final String H_ALGORITHM_SHA256
関連項目:
定数フィールド値
メソッドの詳細

toString

public String toString()
オーバーライド:
クラス Object 内の toString

create

public static DiffieHellmanSession create(AssociationSessionType type,
                                          String modulusBase64,
                                          String generatorBase64)
                                   throws AssociationException
例外:
AssociationException

create

public static DiffieHellmanSession create(AssociationSessionType type,
                                          DHParameterSpec dhParameterSpec)
                                   throws AssociationException
例外:
AssociationException

getDefaultParameter

public static DHParameterSpec getDefaultParameter()

generateRandomParameter

public static DHParameterSpec generateRandomParameter(int primeSize,
                                                      int keySize)

generateKeyPair

protected static KeyPair generateKeyPair(DHParameterSpec dhSpec)

getType

public AssociationSessionType getType()

getModulus

public String getModulus()
Gets the modulus for the Diffie-Hellman key echange. This is the value passed in the openid.dh_modulus association request parameter.

戻り値:
The base 64 encoded two's-complement representation of the modulus: base64(btwoc(p))

getGenerator

public String getGenerator()
Gets the generator for the Diffie-Hellman key echange. This is the value passed in the openid.dh_gen association request parameter.

戻り値:
The base 64 encoded two's-complement representation of the generator: base64(btwoc(g))

getPublicKey

public String getPublicKey()
Get the Diffie-Hellman public key. This is the value passed in the openid.dh_consumer_public association request parameter and the value passed in the openid.dh_server_public association response parameter.

戻り値:
The base 64 encoded two's-complement representation of the public key: base64(btwoc(g ^ x mod p))

getPrivateKey

protected DHPrivateKey getPrivateKey()

encryptMacKey

public String encryptMacKey(byte[] macKey,
                            String consumerPublicKeyBase64)
                     throws AssociationException
Encrypts the association MAC key. The encryption takes palce on the server side (aka OP). This is the value passed in the openid.enc_mac_key association response parameter.

パラメータ:
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.
戻り値:
The base 64 encoded two's-complement representation of the encrypted mac key: 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.

decryptMacKey

public byte[] decryptMacKey(String encMacKeyBase64,
                            String serverPublicKeyBase64)
                     throws AssociationException
Decrypts the association AMC key. The decryption takes palce on the consumer side (aka RP).

パラメータ:
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.
戻り値:
The MAC key in binary format.
例外:
AssociationException - if the lengths of the encrypted mac key and digest of Diffie-Hellman shared secret do not match.

publicKeyToString

protected static String publicKeyToString(DHPublicKey publicKey)

stringToPublicKey

protected DHPublicKey stringToPublicKey(String publicKeyBase64)

getDigestedZZ

protected byte[] getDigestedZZ(String otherPublicKeyBase64)

isDhSupported

public static boolean isDhSupported(AssociationSessionType type)

isDhShaSupported

public static boolean isDhShaSupported(String shaAlgorithm)

isDhSha1Supported

public static boolean isDhSha1Supported()

isDhSha256Supported

public static boolean isDhSha256Supported()

Tsukuyomi OpenID
0.2.0

Copyright © 2008 Project Tsukuyomi. All Rights Reserved.