private void initCipherEncrypt(McElieceCCA2PublicKeyParameters pubKey) { this.messDigest = pubKey.getParameters().getDigest(); n = pubKey.getN(); k = pubKey.getK(); t = pubKey.getT(); }
/** * Return the keyData to encode in the SubjectPublicKeyInfo structure. * <p> * The ASN.1 definition of the key structure is * <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() { McElieceCCA2PublicKey key = new McElieceCCA2PublicKey(params.getN(), params.getT(), params.getG(), Utils.getDigAlgId(params.getDigest())); AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.mcElieceCca2); try { SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(algorithmIdentifier, key); return subjectPublicKeyInfo.getEncoded(); } catch (IOException e) { return null; } }
/** * @return the length of the code */ public int getN() { return params.getN(); }
public PublicKey generatePublic(SubjectPublicKeyInfo pki) throws IOException { // get the inner type inside the BIT STRING ASN1Primitive innerType = pki.parsePublicKey(); McElieceCCA2PublicKey key = McElieceCCA2PublicKey.getInstance(innerType); return new BCMcElieceCCA2PublicKey(new McElieceCCA2PublicKeyParameters(key.getN(), key.getT(), key.getG(), Utils.getDigest(key.getDigest()).getAlgorithmName())); }
/** * @return the generator matrix */ public GF2Matrix getG() { return params.getG(); }
/** * @return the dimension of the code */ public int getK() { return params.getK(); }
/** * @return the error correction capability of the code */ public int getT() { return params.getT(); }
/** * The McEliece encryption primitive. * * @param pubKey the public key * @param m the message vector * @param z the error vector * @return <tt>m*G + z</tt> */ public static GF2Vector encryptionPrimitive(McElieceCCA2PublicKeyParameters pubKey, GF2Vector m, GF2Vector z) { GF2Matrix matrixG = pubKey.getMatrixG(); Vector mG = matrixG.leftMultiplyLeftCompactForm(m); return (GF2Vector)mG.add(z); }
public int getKeySize(McElieceCCA2KeyParameters key) throws IllegalArgumentException { if (key instanceof McElieceCCA2PublicKeyParameters) { return ((McElieceCCA2PublicKeyParameters)key).getN(); } if (key instanceof McElieceCCA2PrivateKeyParameters) { return ((McElieceCCA2PrivateKeyParameters)key).getN(); } throw new IllegalArgumentException("unsupported type"); }
return new BCMcElieceCCA2PublicKey(new McElieceCCA2PublicKeyParameters(key.getN(), key.getT(), key.getG(), Utils.getDigest(key.getDigest()).getAlgorithmName()));
public static GF2Vector encryptionPrimitive(McElieceCCA2PublicKeyParameters pubKey, GF2Vector m, GF2Vector z) { GF2Matrix matrixG = pubKey.getG(); Vector mG = matrixG.leftMultiplyLeftCompactForm(m); return (GF2Vector)mG.add(z); }
private void initCipherEncrypt(McElieceCCA2PublicKeyParameters pubKey) { this.sr = sr != null ? sr : new SecureRandom(); this.messDigest = pubKey.getParameters().getDigest(); n = pubKey.getN(); k = pubKey.getK(); t = pubKey.getT(); }
/** * @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().toString(); return result; }
public int getKeySize(McElieceCCA2KeyParameters key) throws IllegalArgumentException { if (key instanceof McElieceCCA2PublicKeyParameters) { return ((McElieceCCA2PublicKeyParameters)key).getN(); } if (key instanceof McElieceCCA2PrivateKeyParameters) { return ((McElieceCCA2PrivateKeyParameters)key).getN(); } throw new IllegalArgumentException("unsupported type"); }
McElieceCCA2PublicKeyParameters pubKey = new McElieceCCA2PublicKeyParameters(n, t, shortG, mcElieceCCA2Params.getParameters().getDigest()); McElieceCCA2PrivateKeyParameters privKey = new McElieceCCA2PrivateKeyParameters(n, k, field, gp, p, mcElieceCCA2Params.getParameters().getDigest());
/** * The McEliece encryption primitive. * * @param pubKey the public key * @param m the message vector * @param z the error vector * @return <tt>m*G + z</tt> */ public static GF2Vector encryptionPrimitive(McElieceCCA2PublicKeyParameters pubKey, GF2Vector m, GF2Vector z) { GF2Matrix matrixG = pubKey.getG(); Vector mG = matrixG.leftMultiplyLeftCompactForm(m); return (GF2Vector)mG.add(z); }