Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Cryptonite and bytes #73

Closed
Ericson2314 opened this issue Mar 8, 2016 · 2 comments
Closed

Cryptonite and bytes #73

Ericson2314 opened this issue Mar 8, 2016 · 2 comments

Comments

@Ericson2314
Copy link

Instead of using an explicit mutable context, and using IO, one can also hide everything in this Monad. I doubt this is better in all cases, but it might be more convenient in some. ekmett/bytes#25

@vincenthz
Copy link
Member

bytes doesn't support any of the ByteArrayAccess / ByteArray classes (from memory). Also in some places I need to have exact control on how things are represented/copied for security reason, for example HMAC where the hash need to be done in a specific fashion so as not to have additional copy of your key in memory.

@Ericson2314
Copy link
Author

To be clear, I was thinking an additional interface, not replacing the memory classes. Also, while that issue mentioned encryption and hashing, I was thinking mostly about that latter. Specifically, I think https://hackage.haskell.org/package/cryptonite-0.13/docs/Crypto-Hash-IO.html#t:HashAlgorithm is powerful enough for

instance HashAlgorithm h => MonadPut (Hash h) where
  -- ...

There is no HashAlgorithm a => HashAlgorithm (HMAC a) instance, so I am less concerned, but what exactly is the problem here? I'd assume a similarly constructed HMACMonad would have to be eliminated with a key, something like:

runHMACMonad :: (HashAlgorithm a, ByteArrayAccess key) => HMACMonad a -> key -> Digest a

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants