FileDocCategorySizeDatePackage
JCEDHPublicKey.javaAPI DocAndroid 1.5 API3404Wed May 06 22:41:06 BST 2009org.bouncycastle.jce.provider

JCEDHPublicKey

public class JCEDHPublicKey extends Object implements DHPublicKey

Fields Summary
private BigInteger
y
private DHParameterSpec
dhSpec
Constructors Summary
JCEDHPublicKey(DHPublicKeySpec spec)

        this.y = spec.getY();
        this.dhSpec = new DHParameterSpec(spec.getP(), spec.getG());
    
JCEDHPublicKey(DHPublicKey key)

        this.y = key.getY();
        this.dhSpec = key.getParams();
    
JCEDHPublicKey(org.bouncycastle.crypto.params.DHPublicKeyParameters params)

        this.y = params.getY();
        this.dhSpec = new DHParameterSpec(params.getParameters().getP(), params.getParameters().getG(), 0);
    
JCEDHPublicKey(BigInteger y, DHParameterSpec dhSpec)

        this.y = y;
        this.dhSpec = dhSpec;
    
JCEDHPublicKey(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo info)

        DHParameter             params = new DHParameter((ASN1Sequence)info.getAlgorithmId().getParameters());
        DERInteger              derY = null;

        try
        {
            derY = (DERInteger)info.getPublicKey();
        }
        catch (IOException e)
        {
            throw new IllegalArgumentException("invalid info structure in DH public key");
        }

        this.y = derY.getValue();
        if (params.getL() != null)
        {
            this.dhSpec = new DHParameterSpec(params.getP(), params.getG(), params.getL().intValue());
        }
        else
        {
            this.dhSpec = new DHParameterSpec(params.getP(), params.getG());
        }
    
Methods Summary
public java.lang.StringgetAlgorithm()

        return "DH";
    
public byte[]getEncoded()

        SubjectPublicKeyInfo    info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.dhpublicnumber, new DHParameter(dhSpec.getP(), dhSpec.getG(), dhSpec.getL()).getDERObject()), new DERInteger(y));

        return info.getDEREncoded();
    
public java.lang.StringgetFormat()

        return "X.509";
    
public javax.crypto.spec.DHParameterSpecgetParams()

        return dhSpec;
    
public java.math.BigIntegergetY()

        return y;
    
private voidreadObject(java.io.ObjectInputStream in)

        this.y = (BigInteger)in.readObject();
        this.dhSpec = new DHParameterSpec((BigInteger)in.readObject(), (BigInteger)in.readObject(), in.readInt());
    
private voidwriteObject(java.io.ObjectOutputStream out)

        out.writeObject(this.getY());
        out.writeObject(dhSpec.getP());
        out.writeObject(dhSpec.getG());
        out.writeInt(dhSpec.getL());