use of co.krypt.krypton.pgp.packet.MPInt in project krypton-android by kryptco.
the class RSASSHKeyPair method pgpPublicKeyData.
@Override
public PublicKeyData pgpPublicKeyData() {
RSAPublicKey rsaPub = (RSAPublicKey) keyPair.getPublic();
byte[] n = rsaPub.getModulus().toByteArray();
byte[] e = rsaPub.getPublicExponent().toByteArray();
return new RSAPublicKeyData(new MPInt(n), new MPInt(e));
}
use of co.krypt.krypton.pgp.packet.MPInt in project krypton-android by kryptco.
the class EdSSHKeyPair method pgpSign.
@Override
public Signature pgpSign(HashAlgorithm hash, byte[] data) throws PGPException, NoSuchAlgorithmException, CryptoException, SignatureException, NoSuchProviderException, InvalidKeyException, InvalidKeySpecException {
byte[] signatureBytes = signDigest(hash.digest().digest(data));
if (signatureBytes.length != 64) {
throw new SodiumException("unexpected signature length");
}
byte[] r = Arrays.copyOfRange(signatureBytes, 0, 32);
byte[] s = Arrays.copyOfRange(signatureBytes, 32, 64);
return new Ed25519Signature(new MPInt(r), new MPInt(s));
}
Aggregations