private void writeObject( ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeObject(elSpec.getP()); out.writeObject(elSpec.getG()); }
private void writeObject( ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeObject(elSpec.getP()); out.writeObject(elSpec.getG()); } }
private void writeObject( ObjectOutputStream out) throws IOException { out.writeObject(this.getY()); out.writeObject(elSpec.getP()); out.writeObject(elSpec.getG()); } }
private void writeObject( ObjectOutputStream out) throws IOException { out.writeObject(this.getX()); out.writeObject(elSpec.getP()); out.writeObject(elSpec.getG()); }
public DHParameterSpec getParams() { return new DHParameterSpec(elSpec.getP(), elSpec.getG()); }
public DHParameterSpec getParams() { return new DHParameterSpec(elSpec.getP(), elSpec.getG()); }
public DHParameterSpec getParams() { return new DHParameterSpec(elSpec.getP(), elSpec.getG()); }
public DHParameterSpec getParams() { return new DHParameterSpec(elSpec.getP(), elSpec.getG()); }
/** * Return the X.509 ASN.1 structure ElGamalParameter. * <pre> * ElGamalParameter ::= SEQUENCE { * prime INTEGER, -- p * base INTEGER, -- g} * </pre> */ protected byte[] engineGetEncoded() { ElGamalParameter elP = new ElGamalParameter(currentSpec.getP(), currentSpec.getG()); try { return elP.getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new RuntimeException("Error encoding ElGamalParameters"); } }
protected AlgorithmParameterSpec localEngineGetParameterSpec( Class paramSpec) throws InvalidParameterSpecException { if (paramSpec == ElGamalParameterSpec.class || paramSpec == AlgorithmParameterSpec.class) { return currentSpec; } else if (paramSpec == DHParameterSpec.class) { return new DHParameterSpec(currentSpec.getP(), currentSpec.getG()); } throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object."); }
JCEElGamalPublicKey( ElGamalPublicKeySpec spec) { this.y = spec.getY(); this.elSpec = new ElGamalParameterSpec(spec.getParams().getP(), spec.getParams().getG()); }
BCElGamalPublicKey( ElGamalPublicKeySpec spec) { this.y = spec.getY(); this.elSpec = new ElGamalParameterSpec(spec.getParams().getP(), spec.getParams().getG()); }
BCElGamalPrivateKey( ElGamalPrivateKeySpec spec) { this.x = spec.getX(); this.elSpec = new ElGamalParameterSpec(spec.getParams().getP(), spec.getParams().getG()); }
JCEElGamalPrivateKey( ElGamalPrivateKeySpec spec) { this.x = spec.getX(); this.elSpec = new ElGamalParameterSpec(spec.getParams().getP(), spec.getParams().getG()); }
public byte[] getEncoded() { return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(elSpec.getP(), elSpec.getG())), new ASN1Integer(y)); }
/** * Return a PKCS8 representation of the key. The sequence returned * represents a full PrivateKeyInfo object. * * @return a PKCS8 representation of the key. */ public byte[] getEncoded() { return KeyUtil.getEncodedPrivateKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(elSpec.getP(), elSpec.getG())), new ASN1Integer(getX())); }
public byte[] getEncoded() { try { SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(elSpec.getP(), elSpec.getG())), new ASN1Integer(y)); return info.getEncoded(ASN1Encoding.DER); } catch (IOException e) { return null; } }
/** * Return a PKCS8 representation of the key. The sequence returned * represents a full PrivateKeyInfo object. * * @return a PKCS8 representation of the key. */ public byte[] getEncoded() { try { PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(elSpec.getP(), elSpec.getG())), new ASN1Integer(getX())); return info.getEncoded(ASN1Encoding.DER); } catch (IOException e) { return null; } }
static public AsymmetricKeyParameter generatePublicKeyParameter( PublicKey key) throws InvalidKeyException { if (key instanceof ElGamalPublicKey) { ElGamalPublicKey k = (ElGamalPublicKey)key; return new ElGamalPublicKeyParameters(k.getY(), new ElGamalParameters(k.getParameters().getP(), k.getParameters().getG())); } else if (key instanceof DHPublicKey) { DHPublicKey k = (DHPublicKey)key; return new ElGamalPublicKeyParameters(k.getY(), new ElGamalParameters(k.getParams().getP(), k.getParams().getG())); } throw new InvalidKeyException("can't identify public key for El Gamal."); }
static public AsymmetricKeyParameter generatePrivateKeyParameter( PrivateKey key) throws InvalidKeyException { if (key instanceof ElGamalPrivateKey) { ElGamalPrivateKey k = (ElGamalPrivateKey)key; return new ElGamalPrivateKeyParameters(k.getX(), new ElGamalParameters(k.getParameters().getP(), k.getParameters().getG())); } else if (key instanceof DHPrivateKey) { DHPrivateKey k = (DHPrivateKey)key; return new ElGamalPrivateKeyParameters(k.getX(), new ElGamalParameters(k.getParams().getP(), k.getParams().getG())); } throw new InvalidKeyException("can't identify private key for El Gamal."); } }