/** * @return the finite field */ public GF2mField getField() { return params.getField(); }
/** * @return the irreducible Goppa polynomial */ public PolynomialGF2mSmallM getGoppaPoly() { return params.getGoppaPoly(); }
/** * @return the canonical check matrix */ public GF2Matrix getH() { return params.getH(); }
/** * @return the hash code of this key */ public int hashCode() { int code = params.getK(); code = code * 37 + params.getN(); code = code * 37 + params.getField().hashCode(); code = code * 37 + params.getGoppaPoly().hashCode(); code = code * 37 + params.getP1().hashCode(); code = code * 37 + params.getP2().hashCode(); return code * 37 + params.getSInv().hashCode(); }
public PrivateKey generatePrivate(PrivateKeyInfo pki) throws IOException { // get the inner type inside the BIT STRING ASN1Primitive innerType = pki.parsePrivateKey().toASN1Primitive(); McEliecePrivateKey key = McEliecePrivateKey.getInstance(innerType); return new BCMcEliecePrivateKey(new McEliecePrivateKeyParameters(key.getN(), key.getK(), key.getField(), key.getGoppaPoly(), key.getP1(), key.getP2(), key.getSInv())); }
/** * @return the length of the code */ public int getN() { return params.getN(); }
/** * @return the matrix for computing square roots in <tt>(GF(2^m))^t</tt> */ public PolynomialGF2mSmallM[] getQInv() { return params.getQInv(); }
/** * @return the k x k random binary non-singular matrix S */ public GF2Matrix getSInv() { return params.getSInv(); }
/** * @return the dimension of the code */ public int getK() { return params.getK(); }
/** * @return the permutation used to compute the public generator matrix */ public Permutation getP2() { return params.getP2(); }
/** * @return the permutation used to generate the systematic check matrix */ public Permutation getP1() { return params.getP1(); }
static public AsymmetricKeyParameter generatePrivateKeyParameter( PrivateKey key) throws InvalidKeyException { if (key instanceof BCMcEliecePrivateKey) { BCMcEliecePrivateKey k = (BCMcEliecePrivateKey)key; return new McEliecePrivateKeyParameters(k.getN(), k.getK(), k.getField(), k.getGoppaPoly(), k.getP1(), k.getP2(), k.getSInv()); } throw new InvalidKeyException("can't identify McEliece private key."); } }
/** * Return the key size of the given key object. * * @param key the McElieceKeyParameters object * @return the keysize of the given key object */ public int getKeySize(McElieceKeyParameters key) { if (key instanceof McEliecePublicKeyParameters) { return ((McEliecePublicKeyParameters)key).getN(); } if (key instanceof McEliecePrivateKeyParameters) { return ((McEliecePrivateKeyParameters)key).getN(); } throw new IllegalArgumentException("unsupported type"); }
return new BCMcEliecePrivateKey(new McEliecePrivateKeyParameters(key.getN(), key.getK(), key.getField(), key.getGoppaPoly(), key.getP1(), key.getP2(), key.getSInv()));
/** * Return the key size of the given key object. * * @param key the McElieceKeyParameters object * @return the keysize of the given key object */ public int getKeySize(McElieceKeyParameters key) { if (key instanceof McEliecePublicKeyParameters) { return ((McEliecePublicKeyParameters)key).getN(); } if (key instanceof McEliecePrivateKeyParameters) { return ((McEliecePrivateKeyParameters)key).getN(); } throw new IllegalArgumentException("unsupported type"); }