add support for ciphers without encryption.
This commit is contained in:
parent
54640db618
commit
a78162e298
4 changed files with 17 additions and 3 deletions
|
@ -205,7 +205,17 @@ decryptData (EncryptedData econtent) = do
|
|||
let writekey = cstKey cst
|
||||
|
||||
case cipherF cipher of
|
||||
CipherNoneF -> fail "none decrypt"
|
||||
CipherNoneF -> do
|
||||
let contentlen = B.length econtent - digestSize
|
||||
case partition3 econtent (contentlen, digestSize, 0) of
|
||||
Nothing ->
|
||||
throwError $ Error_Misc "partition3 failed"
|
||||
Just (content, mac, _) ->
|
||||
return $ CipherData
|
||||
{ cipherDataContent = content
|
||||
, cipherDataMAC = Just mac
|
||||
, cipherDataPadding = Nothing
|
||||
}
|
||||
CipherBlockF _ decryptF -> do
|
||||
{- update IV -}
|
||||
let (iv, econtent') =
|
||||
|
|
|
@ -144,7 +144,7 @@ encryptData content = do
|
|||
let writekey = cstKey cst
|
||||
|
||||
econtent <- case cipherF cipher of
|
||||
CipherNoneF -> fail "none encrypt"
|
||||
CipherNoneF -> return content
|
||||
CipherBlockF encrypt _ -> do
|
||||
let iv = cstIV cst
|
||||
let e = encrypt writekey iv (B.concat [ content, padding ])
|
||||
|
|
|
@ -33,6 +33,8 @@ cipher_test cipher = run_test n t
|
|||
key <- B.pack <$> arbitraryKey cipher
|
||||
t <- B.pack <$> arbitraryText cipher
|
||||
return $ stream ktoi enc dec key t
|
||||
CipherNoneF -> do
|
||||
return True
|
||||
block e d key iv t = (d key iv . e key iv) t == t
|
||||
stream ktoi e d key t = (fst . d iv . fst . e iv) t == t
|
||||
where iv = ktoi key
|
||||
|
|
|
@ -11,7 +11,9 @@ supportedVersions = [SSL3, TLS10, TLS11]
|
|||
|
||||
supportedCiphers :: [Cipher]
|
||||
supportedCiphers =
|
||||
[ cipher_AES128_SHA1
|
||||
[ cipher_null_MD5
|
||||
, cipher_null_SHA1
|
||||
, cipher_AES128_SHA1
|
||||
, cipher_AES256_SHA1
|
||||
, cipher_RC4_128_MD5
|
||||
, cipher_RC4_128_SHA1
|
||||
|
|
Loading…
Reference in a new issue