@Test public void testCreatePBKDF2Crypto() { Crypto crypto = Crypto.createPBKDF2Crypto(SampleKey.PASSWORD, prvKeyBytes); assertTrue(crypto instanceof PBKDF2Crypto); assertEquals(Crypto.CTR, crypto.getCipher()); assertNotNull(crypto.getCipherparams()); assertNotNull(crypto.getCipherparams().getIv()); assertEquals(32, crypto.getCipherparams().getIv().length()); assertEquals(PBKDF2Crypto.PBKDF2, crypto.getKdf()); assertTrue(crypto.getKdfparams() instanceof PBKDF2Params); PBKDF2Params params = (PBKDF2Params)crypto.getKdfparams(); assertEquals(PBKDF2Params.C_LIGHT, params.getC()); assertEquals(PBKDF2Params.PRF, params.getPrf()); assertEquals(KDFParams.DK_LEN, params.getDklen()); assertNotNull(params.getSalt()); assertEquals(64, params.getSalt().length()); assertNotNull(crypto.getCiphertext()); assertArrayEquals(prvKeyBytes, crypto.decrypt(SampleKey.PASSWORD)); }
public static Crypto createPBKDF2Crypto(String password, byte[] origin) { return createCrypto(password, origin, PBKDF2Crypto.PBKDF2, false); }
Crypto { public static Crypto createPBKDF2Crypto(String password, byte[] origin) { return createCrypto(password, origin, PBKDF2Crypto.PBKDF2, false); } }
Crypto { public static Crypto createPBKDF2Crypto(String password, byte[] origin) { return createCrypto(password, origin, PBKDF2Crypto.PBKDF2, false); } Crypto(); }
Crypto { public static Crypto createPBKDF2Crypto(String password, byte[] origin) { return createCrypto(password, origin, PBKDF2Crypto.PBKDF2, false); } Crypto(); static Crypto createPBKDF2Crypto(String password, byte[] origin); static Crypto createPBKDF2CryptoWithKDFCached(String password, byte[] origin); static Crypto createSCryptCrypto(String password, byte[] origin); boolean verifyPassword(String password); void cacheDerivedKey(String password); void clearCachedDerivedKey(); void validate(); byte[] decrypt(String password); EncPair deriveEncPair(String password, byte[] origin); byte[] decryptEncPair(String password, EncPair encPair); @JsonProperty(required = true) String getCiphertext(); @JsonProperty(required = true) CipherParams getCipherparams(); @JsonProperty(required = true) String getMac(); @JsonProperty(required = true) String getCipher(); @JsonProperty(required = true) String getKdf(); @JsonProperty(required = true) T getKdfparams(); void setCiphertext(String ciphertext); void setMac(String mac); void setCipher(String cipher); void setCipherparams(CipherParams cipherparams); void setKdf(String kdf); void setKdfparams(T kdfparams); @Override boolean equals(Object o); @Override int hashCode(); }
Crypto { public static Crypto createPBKDF2Crypto(String password, byte[] origin) { return createCrypto(password, origin, PBKDF2Crypto.PBKDF2, false); } Crypto(); static Crypto createPBKDF2Crypto(String password, byte[] origin); static Crypto createPBKDF2CryptoWithKDFCached(String password, byte[] origin); static Crypto createSCryptCrypto(String password, byte[] origin); boolean verifyPassword(String password); void cacheDerivedKey(String password); void clearCachedDerivedKey(); void validate(); byte[] decrypt(String password); EncPair deriveEncPair(String password, byte[] origin); byte[] decryptEncPair(String password, EncPair encPair); @JsonProperty(required = true) String getCiphertext(); @JsonProperty(required = true) CipherParams getCipherparams(); @JsonProperty(required = true) String getMac(); @JsonProperty(required = true) String getCipher(); @JsonProperty(required = true) String getKdf(); @JsonProperty(required = true) T getKdfparams(); void setCiphertext(String ciphertext); void setMac(String mac); void setCipher(String cipher); void setCipherparams(CipherParams cipherparams); void setKdf(String kdf); void setKdfparams(T kdfparams); @Override boolean equals(Object o); @Override int hashCode();  }