org.bouncycastle.jcajce.spec.MQVParameterSpec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bouncycastle Show documentation
Show all versions of bouncycastle Show documentation
The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, and certificate generation. This jar
contains APIs for JDK 1.5 and up. The APIs can be used in conjunction with a JCE/JCA provider such as the one
provided with the Bouncy Castle Cryptography APIs.
package org.bouncycastle.jcajce.spec;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.AlgorithmParameterSpec;
import org.bouncycastle.util.Arrays;
/**
* Parameter spec to provide MQV ephemeral keys and user keying material.
*/
public class MQVParameterSpec
implements AlgorithmParameterSpec
{
private final PublicKey ephemeralPublicKey;
private final PrivateKey ephemeralPrivateKey;
private final PublicKey otherPartyEphemeralKey;
private final byte[] userKeyingMaterial;
public MQVParameterSpec(PublicKey ephemeralPublicKey, PrivateKey ephemeralPrivateKey, PublicKey otherPartyEphemeralKey, byte[] userKeyingMaterial)
{
this.ephemeralPublicKey = ephemeralPublicKey;
this.ephemeralPrivateKey = ephemeralPrivateKey;
this.otherPartyEphemeralKey = otherPartyEphemeralKey;
this.userKeyingMaterial = Arrays.clone(userKeyingMaterial);
}
public MQVParameterSpec(PublicKey ephemeralPublicKey, PrivateKey ephemeralPrivateKey, PublicKey otherPartyEphemeralKey)
{
this(ephemeralPublicKey, ephemeralPrivateKey, otherPartyEphemeralKey, null);
}
public MQVParameterSpec(KeyPair ephemeralKeyPair, PublicKey otherPartyEphemeralKey, byte[] userKeyingMaterial)
{
this(ephemeralKeyPair.getPublic(), ephemeralKeyPair.getPrivate(), otherPartyEphemeralKey, userKeyingMaterial);
}
public MQVParameterSpec(PrivateKey ephemeralPrivateKey, PublicKey otherPartyEphemeralKey, byte[] userKeyingMaterial)
{
this(null, ephemeralPrivateKey, otherPartyEphemeralKey, userKeyingMaterial);
}
public MQVParameterSpec(KeyPair ephemeralKeyPair, PublicKey otherPartyEphemeralKey)
{
this(ephemeralKeyPair.getPublic(), ephemeralKeyPair.getPrivate(), otherPartyEphemeralKey, null);
}
public MQVParameterSpec(PrivateKey ephemeralPrivateKey, PublicKey otherPartyEphemeralKey)
{
this(null, ephemeralPrivateKey, otherPartyEphemeralKey, null);
}
public PrivateKey getEphemeralPrivateKey()
{
return ephemeralPrivateKey;
}
public PublicKey getEphemeralPublicKey()
{
return ephemeralPublicKey;
}
public PublicKey getOtherPartyEphemeralKey()
{
return otherPartyEphemeralKey;
}
public byte[] getUserKeyingMaterial()
{
return Arrays.clone(userKeyingMaterial);
}
}