diff options
author | Sergio Giro <sgiro@google.com> | 2016-02-01 18:54:35 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-02-01 18:54:35 +0000 |
commit | 3e75bd6b407dd472c834a50f16aae54cca67ea9c (patch) | |
tree | b5eb091b97b2aade28e5b45a15352125a4a776d7 /bcprov/src/main/java/org/bouncycastle/pqc/crypto/ntru/NTRUSigningPublicKeyParameters.java | |
parent | 9218edabd1ef9852bc2f13115dcadc81b442dd6c (diff) | |
parent | c1040cb5656c3299f1c2d0fe0bd7c44b10466aaf (diff) | |
download | android_external_bouncycastle-3e75bd6b407dd472c834a50f16aae54cca67ea9c.tar.gz android_external_bouncycastle-3e75bd6b407dd472c834a50f16aae54cca67ea9c.tar.bz2 android_external_bouncycastle-3e75bd6b407dd472c834a50f16aae54cca67ea9c.zip |
Merge "Restoring the contents of aosp after"
Diffstat (limited to 'bcprov/src/main/java/org/bouncycastle/pqc/crypto/ntru/NTRUSigningPublicKeyParameters.java')
-rw-r--r-- | bcprov/src/main/java/org/bouncycastle/pqc/crypto/ntru/NTRUSigningPublicKeyParameters.java | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/pqc/crypto/ntru/NTRUSigningPublicKeyParameters.java b/bcprov/src/main/java/org/bouncycastle/pqc/crypto/ntru/NTRUSigningPublicKeyParameters.java deleted file mode 100644 index be51d0a..0000000 --- a/bcprov/src/main/java/org/bouncycastle/pqc/crypto/ntru/NTRUSigningPublicKeyParameters.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.bouncycastle.pqc.crypto.ntru; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.bouncycastle.crypto.params.AsymmetricKeyParameter; -import org.bouncycastle.pqc.math.ntru.polynomial.IntegerPolynomial; - -/** - * A NtruSign public key is essentially a polynomial named <code>h</code>. - */ -public class NTRUSigningPublicKeyParameters - extends AsymmetricKeyParameter -{ - private NTRUSigningParameters params; - public IntegerPolynomial h; - - /** - * Constructs a new public key from a polynomial - * - * @param h the polynomial <code>h</code> which determines the key - * @param params the NtruSign parameters to use - */ - public NTRUSigningPublicKeyParameters(IntegerPolynomial h, NTRUSigningParameters params) - { - super(false); - this.h = h; - this.params = params; - } - - /** - * Converts a byte array to a polynomial <code>h</code> and constructs a new public key - * - * @param b an encoded polynomial - * @param params the NtruSign parameters to use - */ - public NTRUSigningPublicKeyParameters(byte[] b, NTRUSigningParameters params) - { - super(false); - h = IntegerPolynomial.fromBinary(b, params.N, params.q); - this.params = params; - } - - /** - * Reads a polynomial <code>h</code> from an input stream and constructs a new public key - * - * @param is an input stream - * @param params the NtruSign parameters to use - */ - public NTRUSigningPublicKeyParameters(InputStream is, NTRUSigningParameters params) - throws IOException - { - super(false); - h = IntegerPolynomial.fromBinary(is, params.N, params.q); - this.params = params; - } - - - /** - * Converts the key to a byte array - * - * @return the encoded key - */ - public byte[] getEncoded() - { - return h.toBinary(params.q); - } - - /** - * Writes the key to an output stream - * - * @param os an output stream - * @throws IOException - */ - public void writeTo(OutputStream os) - throws IOException - { - os.write(getEncoded()); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ((h == null) ? 0 : h.hashCode()); - result = prime * result + ((params == null) ? 0 : params.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - NTRUSigningPublicKeyParameters other = (NTRUSigningPublicKeyParameters)obj; - if (h == null) - { - if (other.h != null) - { - return false; - } - } - else if (!h.equals(other.h)) - { - return false; - } - if (params == null) - { - if (other.params != null) - { - return false; - } - } - else if (!params.equals(other.params)) - { - return false; - } - return true; - } -}
\ No newline at end of file |