org.spongycastle.crypto.digests.SHA1Digest Java Examples
The following examples show how to use
org.spongycastle.crypto.digests.SHA1Digest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ECIESCoder.java From wkcwallet-java with Apache License 2.0 | 6 votes |
/** * Encryption equivalent to the Crypto++ default ECIES<ECP> settings: * * DL_KeyAgreementAlgorithm: DL_KeyAgreementAlgorithm_DH<struct ECPPoint,struct EnumToType<enum CofactorMultiplicationOption,0> > * DL_KeyDerivationAlgorithm: DL_KeyDerivationAlgorithm_P1363<struct ECPPoint,0,class P1363_KDF2<class SHA1> > * DL_SymmetricEncryptionAlgorithm: DL_EncryptionAlgorithm_Xor<class HMAC<class SHA1>,0> * DL_PrivateKey: DL_Key<ECPPoint> * DL_PrivateKey_EC<class ECP> * * Used for Whisper V3 */ public static byte[] decryptSimple(BigInteger privKey, byte[] cipher) throws IOException, InvalidCipherTextException { EthereumIESEngine iesEngine = new EthereumIESEngine( new ECDHBasicAgreement(), new MGF1BytesGeneratorExt(new SHA1Digest(), 1), new HMac(new SHA1Digest()), new SHA1Digest(), null); IESParameters p = new IESParameters(null, null, KEY_SIZE); ParametersWithIV parametersWithIV = new ParametersWithIV(p, new byte[0]); iesEngine.setHashMacKey(false); iesEngine.init(new ECPrivateKeyParameters(privKey, CURVE), parametersWithIV, new ECIESPublicKeyParser(ECKey.CURVE)); return iesEngine.processBlock(cipher, 0, cipher.length); }
Example #2
Source File: ECIESCoder.java From wkcwallet-java with Apache License 2.0 | 5 votes |
/** * Encryption equivalent to the Crypto++ default ECIES<ECP> settings: * * DL_KeyAgreementAlgorithm: DL_KeyAgreementAlgorithm_DH<struct ECPPoint,struct EnumToType<enum CofactorMultiplicationOption,0> > * DL_KeyDerivationAlgorithm: DL_KeyDerivationAlgorithm_P1363<struct ECPPoint,0,class P1363_KDF2<class SHA1> > * DL_SymmetricEncryptionAlgorithm: DL_EncryptionAlgorithm_Xor<class HMAC<class SHA1>,0> * DL_PrivateKey: DL_Key<ECPPoint> * DL_PrivateKey_EC<class ECP> * * Used for Whisper V3 */ public static byte[] encryptSimple(ECPoint pub, byte[] plaintext) throws IOException, InvalidCipherTextException { EthereumIESEngine iesEngine = new EthereumIESEngine( new ECDHBasicAgreement(), new MGF1BytesGeneratorExt(new SHA1Digest(), 1), new HMac(new SHA1Digest()), new SHA1Digest(), null); IESParameters p = new IESParameters(null, null, KEY_SIZE); ParametersWithIV parametersWithIV = new ParametersWithIV(p, new byte[0]); iesEngine.setHashMacKey(false); ECKeyPairGenerator eGen = new ECKeyPairGenerator(); SecureRandom random = new SecureRandom(); KeyGenerationParameters gParam = new ECKeyGenerationParameters(CURVE, random); eGen.init(gParam); // AsymmetricCipherKeyPairGenerator testGen = new AsymmetricCipherKeyPairGenerator() { // ECKey priv = ECKey.fromPrivate(Hex.decode("d0b043b4c5d657670778242d82d68a29d25d7d711127d17b8e299f156dad361a")); // // @Override // public void init(KeyGenerationParameters keyGenerationParameters) { // } // // @Override // public AsymmetricCipherKeyPair generateKeyPair() { // return new AsymmetricCipherKeyPair(new ECPublicKeyParameters(priv.getPubKeyPoint(), CURVE), // new ECPrivateKeyParameters(priv.getPrivKey(), CURVE)); // } // }; EphemeralKeyPairGenerator ephemeralKeyPairGenerator = new EphemeralKeyPairGenerator(/*testGen*/eGen, new ECIESPublicKeyEncoder()); iesEngine.init(new ECPublicKeyParameters(pub, CURVE), parametersWithIV, ephemeralKeyPairGenerator); return iesEngine.processBlock(plaintext, 0, plaintext.length); }
Example #3
Source File: DatabaseAdaptor.java From KeePassJava2 with Apache License 2.0 | 5 votes |
@Override public String getHash() { byte[] toHash = Helpers.hexStringFromUuid(database.getRootGroup().getUuid()).getBytes(); SHA1Digest digest = new SHA1Digest(); byte[] digestBytes = new byte[digest.getDigestSize()]; digest.update(toHash, 0, toHash.length); digest.doFinal(digestBytes, 0); String result = new String(Hex.encodeHex(digestBytes)); return result.toLowerCase(); }
Example #4
Source File: Cryptograph.java From SightRemote with GNU General Public License v3.0 | 4 votes |
private static byte[] sha1MultiHmac(byte[] secret, byte[] data, int bytes) { return getMultiHmac(secret, data, bytes, new SHA1Digest()); }
Example #5
Source File: Cryptograph.java From AndroidAPS with GNU Affero General Public License v3.0 | 4 votes |
private static byte[] sha1MultiHmac(byte[] secret, byte[] data, int bytes) { return getMultiHmac(secret, data, bytes, new SHA1Digest()); }