org.bouncycastle.jcajce.provider.ProvLMSPublicKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bc-fips-debug Show documentation
Show all versions of bc-fips-debug Show documentation
The FIPS 140-2 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-2 level 1. This jar contains the debug version JCE provider and low-level API for the BC-FJA version 1.0.2.3, FIPS Certificate #3514. Please note the debug jar is not certified.
package org.bouncycastle.jcajce.provider;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.crypto.asymmetric.AsymmetricLMSPublicKey;
import org.bouncycastle.jcajce.interfaces.LMSPublicKey;
class ProvLMSPublicKey
implements LMSPublicKey
{
private static final long serialVersionUID = 1L;
private transient AsymmetricLMSPublicKey baseKey;
ProvLMSPublicKey(SubjectPublicKeyInfo keyInfo)
throws IOException
{
this.baseKey = new AsymmetricLMSPublicKey(keyInfo);
}
ProvLMSPublicKey(AsymmetricLMSPublicKey baseKey)
{
this.baseKey = baseKey;
}
/**
* @return name of the algorithm - "LMS"
*/
public final String getAlgorithm()
{
return "LMS";
}
public byte[] getEncoded()
{
return baseKey.getEncoded();
}
public String getFormat()
{
return "X.509";
}
public boolean equals(Object o)
{
if (o == this)
{
return true;
}
if (o instanceof ProvLMSPublicKey)
{
ProvLMSPublicKey otherKey = (ProvLMSPublicKey)o;
return baseKey.equals(otherKey.baseKey);
}
return false;
}
public int hashCode()
{
return baseKey.hashCode();
}
public int getLevels()
{
return baseKey.getL();
}
AsymmetricLMSPublicKey getBaseKey()
{
return baseKey;
}
private void readObject(
ObjectInputStream in)
throws IOException, ClassNotFoundException
{
in.defaultReadObject();
byte[] enc = (byte[])in.readObject();
baseKey = new AsymmetricLMSPublicKey(enc);
}
private void writeObject(
ObjectOutputStream out)
throws IOException
{
out.defaultWriteObject();
out.writeObject(this.getEncoded());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy