public static final EngineFactory<EngineWrapper.TCipher, Cipher> getCustomCipherProvider( boolean letFallbackToDefault, String... providerNames) { return new EngineFactory<EngineWrapper.TCipher, Cipher>( new EngineWrapper.TCipher(), toProviderList(providerNames), letFallbackToDefault); }
public static final EngineFactory<EngineWrapper.TKeyAgreement, KeyAgreement> getCustomKeyAgreementProvider(boolean letFallbackToDefault, String... providerNames) { return new EngineFactory<EngineWrapper.TKeyAgreement, KeyAgreement>( new EngineWrapper.TKeyAgreement(), toProviderList(providerNames), letFallbackToDefault); }
public static final EngineFactory<EngineWrapper.TKeyPairGenerator, KeyPairGenerator> getCustomKeyPairGeneratorProvider(boolean letFallbackToDefault, String... providerNames) { return new EngineFactory<EngineWrapper.TKeyPairGenerator, KeyPairGenerator>( new EngineWrapper.TKeyPairGenerator(), toProviderList(providerNames), letFallbackToDefault); }
/** Returns a new <publicKey, privateKey> KeyPair. */ public static KeyPair newKeyPair() throws GeneralSecurityException { byte[] privateKey = Random.randBytes(Field25519.FIELD_LEN); byte[] publicKey = Ed25519.scalarMultWithBaseToBytes(Ed25519.getHashedScalar(privateKey)); return new KeyPair(publicKey, privateKey); } }
public static final EngineFactory<EngineWrapper.TMac, Mac> getCustomMacProvider( boolean letFallbackToDefault, String... providerNames) { return new EngineFactory<EngineWrapper.TMac, Mac>( new EngineWrapper.TMac(), toProviderList(providerNames), letFallbackToDefault); }
public static final EngineFactory<EngineWrapper.TMessageDigest, MessageDigest> getCustomMessageDigestProvider(boolean letFallbackToDefault, String... providerNames) { return new EngineFactory<EngineWrapper.TMessageDigest, MessageDigest>( new EngineWrapper.TMessageDigest(), toProviderList(providerNames), letFallbackToDefault); }
public static final EngineFactory<EngineWrapper.TKeyFactory, KeyFactory> getCustomKeyFactoryProvider(boolean letFallbackToDefault, String... providerNames) { return new EngineFactory<EngineWrapper.TKeyFactory, KeyFactory>( new EngineWrapper.TKeyFactory(), toProviderList(providerNames), letFallbackToDefault); }
public static final EngineFactory<EngineWrapper.TSignature, Signature> getCustomSignatureProvider( boolean letFallbackToDefault, String... providerNames) { return new EngineFactory<EngineWrapper.TSignature, Signature>( new EngineWrapper.TSignature(), toProviderList(providerNames), letFallbackToDefault); }
/** Returns a new EncryptThenAuthenticate instance using AES-CTR and HMAC. */ public static Aead newAesCtrHmac( final byte[] aesCtrKey, int ivSize, String hmacAlgorithm, final byte[] hmacKey, int tagSize) throws GeneralSecurityException { IndCpaCipher cipher = new AesCtrJceCipher(aesCtrKey, ivSize); SecretKeySpec hmacKeySpec = new SecretKeySpec(hmacKey, "HMAC"); Mac hmac = new MacJce(hmacAlgorithm, hmacKeySpec, tagSize); return new EncryptThenAuthenticate(cipher, hmac, tagSize); }
private static Ed25519.CachedXYT getCachedXYT(Point p) { return new Ed25519.CachedXYT( Field25519.expand(toLittleEndian(p.y.add(p.x).mod(P_BI))), Field25519.expand(toLittleEndian(p.y.subtract(p.x).mod(P_BI))), Field25519.expand(toLittleEndian(D2_BI.multiply(p.x).multiply(p.y).mod(P_BI)))); }
/** * Computes {@code a}*B * where a = a[0]+256*a[1]+...+256^31 a[31] and * B is the Ed25519 base point (x,4/5) with x positive. * * Preconditions: * a[31] <= 127 */ static byte[] scalarMultWithBaseToBytes(byte[] a) { return scalarMultWithBase(a).toBytes(); }
public EcdsaVerifyJce(final ECPublicKey pubKey, HashType hash, EcdsaEncoding encoding) throws GeneralSecurityException { EllipticCurves.checkPublicKey(pubKey); this.signatureAlgorithm = SubtleUtil.toEcdsaAlgo(hash); this.publicKey = pubKey; this.encoding = encoding; }
public EciesAeadHkdfHybridEncrypt( final ECPublicKey recipientPublicKey, final byte[] hkdfSalt, String hkdfHmacAlgo, EllipticCurves.PointFormatType ecPointFormat, EciesAeadHkdfDemHelper demHelper) throws GeneralSecurityException { EllipticCurves.checkPublicKey(recipientPublicKey); this.senderKem = new EciesHkdfSenderKem(recipientPublicKey); this.hkdfSalt = hkdfSalt; this.hkdfHmacAlgo = hkdfHmacAlgo; this.ecPointFormat = ecPointFormat; this.demHelper = demHelper; }
@Override public void verifyMac(final byte[] mac, final byte[] data) throws GeneralSecurityException { if (!Bytes.equal(computeMac(data), mac)) { throw new GeneralSecurityException("invalid MAC"); } } }
/** * If icopy is 1, copies {@code other} into this point. Time invariant wrt to icopy value. */ void copyConditional(CachedXYT other, int icopy) { Curve25519.copyConditional(yPlusX, other.yPlusX, icopy); Curve25519.copyConditional(yMinusX, other.yMinusX, icopy); Curve25519.copyConditional(t2d, other.t2d, icopy); } }
static void quarterRound(int[] x, int a, int b, int c, int d) { x[a] += x[b]; x[d] = rotateLeft(x[d] ^ x[a], 16); x[c] += x[d]; x[b] = rotateLeft(x[b] ^ x[c], 12); x[a] += x[b]; x[d] = rotateLeft(x[d] ^ x[a], 8); x[c] += x[d]; x[b] = rotateLeft(x[b] ^ x[c], 7); } }
/** * Transforms a passed LSB first byte array to an int * * @param bytes that should be transformed to a byte array * @param length amount of the passed {@code bytes} that should be transformed */ public static int byteArrayToInt(byte[] bytes, int length) { return byteArrayToInt(bytes, 0, length); }
/** * Sums two numbers: output += in * * On entry: in is in reduced-size form. */ static void sum(long[] output, long[] in) { sum(output, output, in); }
public byte[] getSymmetricKey() { if (symmetricKey == null) { return null; } else { return symmetricKey.getBytes(); } } }
@Override Snuffle createSnuffleInstance(final byte[] key, int initialCounter) throws InvalidKeyException { return new ChaCha20(key, initialCounter); } }