/** * @return the error correction capability of the code */ public int getT() { return params.getT(); }
public void initCipherEncrypt(McEliecePublicKeyParameters pubKey) { this.sr = sr != null ? sr : new SecureRandom(); n = pubKey.getN(); k = pubKey.getK(); t = pubKey.getT(); cipherTextSize = n >> 3; maxPlainTextSize = (k >> 3); }
/** * @return a human readable form of the key */ public String toString() { String result = "McEliecePublicKey:\n"; result += " length of the code : " + params.getN() + "\n"; result += " error correction capability: " + params.getT() + "\n"; result += " generator matrix : " + params.getG(); return result; }
private void initCipherEncrypt(McEliecePublicKeyParameters pubKey) { this.sr = sr != null ? sr : CryptoServicesRegistrar.getSecureRandom(); n = pubKey.getN(); k = pubKey.getK(); t = pubKey.getT(); cipherTextSize = n >> 3; maxPlainTextSize = (k >> 3); }
/** * @return the hash code of this key */ public int hashCode() { return 37 * (params.getN() + 37 * params.getT()) + params.getG().hashCode(); }
/** * Compare this key with another object. * * @param other the other object * @return the result of the comparison */ public boolean equals(Object other) { if (other instanceof BCMcEliecePublicKey) { BCMcEliecePublicKey otherKey = (BCMcEliecePublicKey)other; return (params.getN() == otherKey.getN()) && (params.getT() == otherKey.getT()) && (params.getG().equals(otherKey.getG())); } return false; }
/** * Return the keyData to encode in the SubjectPublicKeyInfo structure. * <p> * The ASN.1 definition of the key structure is * </p> * <pre> * McEliecePublicKey ::= SEQUENCE { * n Integer -- length of the code * t Integer -- error correcting capability * matrixG OctetString -- generator matrix as octet string * } * </pre> * @return the keyData to encode in the SubjectPublicKeyInfo structure */ public byte[] getEncoded() { McEliecePublicKey key = new McEliecePublicKey(params.getN(), params.getT(), params.getG()); AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.mcEliece); try { SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(algorithmIdentifier, key); return subjectPublicKeyInfo.getEncoded(); } catch (IOException e) { return null; } }