From 9877ccf7fe7df38f8ecc65d01e9b46a98528502f Mon Sep 17 00:00:00 2001 From: iximeow Date: Wed, 26 Nov 2014 23:17:51 -0800 Subject: Add part of CBC mode --- src/utils/CryptoUtils.scala | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/utils/CryptoUtils.scala') diff --git a/src/utils/CryptoUtils.scala b/src/utils/CryptoUtils.scala index 5418895..2b4d38e 100644 --- a/src/utils/CryptoUtils.scala +++ b/src/utils/CryptoUtils.scala @@ -1,5 +1,9 @@ package ixee.cryptopals.utils +import ixee.cryptopals.utils.crypto.CBCCipher +import javax.crypto.Cipher +import javax.crypto.spec.SecretKeySpec + object CryptoUtils { def pkcs7pad(s: String, blockSize: Int) = { @@ -7,4 +11,8 @@ object CryptoUtils { s + s"${padLength.toChar}" * padLength } + def cbcDecryptInstance(ecbCipher: Cipher, key: SecretKeySpec): CBCCipher = { + ecbCipher.init(Cipher.DECRYPT_MODE, key) + new CBCCipher(ecbCipher) + } } -- cgit v1.1