MCPcopy Create free account
hub / github.com/M66B/FairEmail / getKeyPair

Method getKeyPair

app/src/main/java/eu/faircode/email/CloudSync.java:764–776  ·  view source on GitHub ↗
(byte[] salt, String password)

Source from the content-addressed store, hash-verified

762 }
763
764 private static Pair<byte[], byte[]> getKeyPair(byte[] salt, String password)
765 throws NoSuchAlgorithmException, InvalidKeySpecException {
766 // https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
767 SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
768 KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, 310000, 2 * 256);
769 SecretKey secret = keyFactory.generateSecret(keySpec);
770
771 byte[] encoded = secret.getEncoded();
772 int half = encoded.length / 2;
773 return new Pair<>(
774 Arrays.copyOfRange(encoded, 0, half),
775 Arrays.copyOfRange(encoded, half, half + half));
776 }
777
778 private static byte[] getIv(long revision) {
779 byte[] iv = ByteBuffer.allocate(12)

Callers 1

_callMethod · 0.95

Calls 1

getInstanceMethod · 0.45

Tested by

no test coverage detected