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/gmss/GMSSParameters.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/gmss/GMSSParameters.java')
-rw-r--r-- | bcprov/src/main/java/org/bouncycastle/pqc/crypto/gmss/GMSSParameters.java | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/pqc/crypto/gmss/GMSSParameters.java b/bcprov/src/main/java/org/bouncycastle/pqc/crypto/gmss/GMSSParameters.java deleted file mode 100644 index aa89f76..0000000 --- a/bcprov/src/main/java/org/bouncycastle/pqc/crypto/gmss/GMSSParameters.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.bouncycastle.pqc.crypto.gmss; - -import org.bouncycastle.util.Arrays; - -/** - * This class provides a specification for the GMSS parameters that are used by - * the GMSSKeyPairGenerator and GMSSSignature classes. - * - * @see org.bouncycastle.pqc.crypto.gmss.GMSSKeyPairGenerator - */ -public class GMSSParameters -{ - /** - * The number of authentication tree layers. - */ - private int numOfLayers; - - /** - * The height of the authentication trees of each layer. - */ - private int[] heightOfTrees; - - /** - * The Winternitz Parameter 'w' of each layer. - */ - private int[] winternitzParameter; - - /** - * The parameter K needed for the authentication path computation - */ - private int[] K; - - /** - * The constructor for the parameters of the GMSSKeyPairGenerator. - * - * @param layers the number of authentication tree layers - * @param heightOfTrees the height of the authentication trees - * @param winternitzParameter the Winternitz Parameter 'w' of each layer - * @param K parameter for authpath computation - */ - public GMSSParameters(int layers, int[] heightOfTrees, int[] winternitzParameter, int[] K) - throws IllegalArgumentException - { - init(layers, heightOfTrees, winternitzParameter, K); - } - - private void init(int layers, int[] heightOfTrees, - int[] winternitzParameter, int[] K) - throws IllegalArgumentException - { - boolean valid = true; - String errMsg = ""; - this.numOfLayers = layers; - if ((numOfLayers != winternitzParameter.length) - || (numOfLayers != heightOfTrees.length) - || (numOfLayers != K.length)) - { - valid = false; - errMsg = "Unexpected parameterset format"; - } - for (int i = 0; i < numOfLayers; i++) - { - if ((K[i] < 2) || ((heightOfTrees[i] - K[i]) % 2 != 0)) - { - valid = false; - errMsg = "Wrong parameter K (K >= 2 and H-K even required)!"; - } - - if ((heightOfTrees[i] < 4) || (winternitzParameter[i] < 2)) - { - valid = false; - errMsg = "Wrong parameter H or w (H > 3 and w > 1 required)!"; - } - } - - if (valid) - { - this.heightOfTrees = Arrays.clone(heightOfTrees); - this.winternitzParameter = Arrays.clone(winternitzParameter); - this.K = Arrays.clone(K); - } - else - { - throw new IllegalArgumentException(errMsg); - } - } - - public GMSSParameters(int keySize) - throws IllegalArgumentException - { - if (keySize <= 10) - { // create 2^10 keys - int[] defh = {10}; - int[] defw = {3}; - int[] defk = {2}; - this.init(defh.length, defh, defw, defk); - } - else if (keySize <= 20) - { // create 2^20 keys - int[] defh = {10, 10}; - int[] defw = {5, 4}; - int[] defk = {2, 2}; - this.init(defh.length, defh, defw, defk); - } - else - { // create 2^40 keys, keygen lasts around 80 seconds - int[] defh = {10, 10, 10, 10}; - int[] defw = {9, 9, 9, 3}; - int[] defk = {2, 2, 2, 2}; - this.init(defh.length, defh, defw, defk); - } - } - - /** - * Returns the number of levels of the authentication trees. - * - * @return The number of levels of the authentication trees. - */ - public int getNumOfLayers() - { - return numOfLayers; - } - - /** - * Returns the array of height (for each layer) of the authentication trees - * - * @return The array of height (for each layer) of the authentication trees - */ - public int[] getHeightOfTrees() - { - return Arrays.clone(heightOfTrees); - } - - /** - * Returns the array of WinternitzParameter (for each layer) of the - * authentication trees - * - * @return The array of WinternitzParameter (for each layer) of the - * authentication trees - */ - public int[] getWinternitzParameter() - { - return Arrays.clone(winternitzParameter); - } - - /** - * Returns the parameter K needed for authentication path computation - * - * @return The parameter K needed for authentication path computation - */ - public int[] getK() - { - return Arrays.clone(K); - } -} |