Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gadget and Refactored Memory and SecureMemory #54

Closed
satvikc opened this issue Aug 20, 2013 · 9 comments
Closed

Gadget and Refactored Memory and SecureMemory #54

satvikc opened this issue Aug 20, 2013 · 9 comments

Comments

@satvikc
Copy link
Contributor

satvikc commented Aug 20, 2013

I have added the gadget class and refactored memory and SecureMemory.

  • I have moved from Using the state monad to just a function which takes BookKeeper as the argument. It was not possible to compose memory instances if we were using state monad.
  • Also I have moved from mmap to posix_memalign and wrote tests to detect if it is available. The code is portable in the sense that it sets and checks necessary flags.
  • MAC and Hash are broken because of the new gadget interface.

Here is the link https://github.com/satvikc/raaz/tree/x-memory/raaz-primitives/Raaz

@satvikc
Copy link
Contributor Author

satvikc commented Aug 20, 2013

I am not sure how to refactor Hash.hs and MAC.hs for the new Gadget interface. Can you give some guide lines for the same.

@piyush-kurur
Copy link
Member

On Tue, Aug 20, 2013 at 04:07:35AM -0700, satvikc wrote:

I am not sure how to refactor Hash.hs and MAC.hs for the new Gadget interface. Can you give some guide lines for the same.

We can discuss this in person sometime.

Regards

ppk

@satvikc
Copy link
Contributor Author

satvikc commented Aug 22, 2013

I have rewritten the Hash and MAC but I ran into few problems

  • I am not sure how to define finalize for HMAC g as I require outer pad and I have no way of getting that from HMAC g.
  • Also I had to add a function reInitialize :: g -> PrimitiveOf g -> IV (PrimitiveOf g) in HashGadget to make rest of the HMAC work.

You can look at the code here

@piyush-kurur
Copy link
Member

On Thu, Aug 22, 2013 at 11:39:58AM -0700, satvikc wrote:

I have rewritten the Hash and MAC but I ran into few problems

  • I am not sure how to define finalize for HMAC g as I require outer pad and I have no way of getting that from HMAC g.

Define IV (HMAC h) = (IV h, IV h)

The IV (HMAC h) should be (IV h, IV h). The first IV h is for the
inner pad (i.e. hash of the inner pad) and the second for the IV of
the outer pad. You might need to store the IV h inside a memory
element so you might need some storable or something like that
instance.

Regards

ppk

@satvikc
Copy link
Contributor Author

satvikc commented Aug 23, 2013

the type of finalize is g -> IO (PrimitiveOf g. And I have no way of
inspecting the memory component of g.

On Fri, Aug 23, 2013 at 10:14 AM, Piyush P Kurur
notifications@github.comwrote:

On Thu, Aug 22, 2013 at 11:39:58AM -0700, satvikc wrote:

I have rewritten the Hash and MAC but I ran into few problems

  • I am not sure how to define finalize for HMAC g as I require outer
    pad and I have no way of getting that from HMAC g.

Define IV (HMAC h) = (IV h, IV h)

The IV (HMAC h) should be (IV h, IV h). The first IV h is for the
inner pad (i.e. hash of the inner pad) and the second for the IV of
the outer pad. You might need to store the IV h inside a memory
element so you might need some storable or something like that
instance.

Regards

ppk


Reply to this email directly or view it on GitHubhttps://github.com/piyush-kurur/raaz/issues/54#issuecomment-23143189
.


Satvik Chauhan
Fourth Year Under Graduate Student
Deptt. of Computer Science and Engineering
Indian Institute of Technology Kanpur
Kanpur-208016, INDIA
Email: mystic.satvik@gmail.com , satvikc@iitk.ac.in


@satvikc
Copy link
Contributor Author

satvikc commented Aug 23, 2013

CryptoArray doesn't have a memory instance.

MemoryOf g has Memory typeclass constraint, so I can put neither CryptoArray nor ForeignCryptoPtr directly into MemoryOf (HMACGadget g). The only solution which I could think of is to define a newtype with a Memory instance.

@satvikc
Copy link
Contributor Author

satvikc commented Aug 23, 2013

I have refactored the code using the above solution. I am not sure how to solve the following error from

instance CryptoPrimitive p => CryptoPrimitive (HMAC p) where
  type Recommended (HMAC p) = HMAC (Recommended p)
  type Reference   (HMAC p) = HMAC (Reference p)
Raaz/Primitives/Hash.hs:250:10:
    Could not deduce (PrimitiveOf (HMAC (Recommended p)) ~ HMAC p)
    from the context (CryptoPrimitive p)
      bound by the instance declaration
      at Raaz/Primitives/Hash.hs:250:10-54
    In the instance declaration for `CryptoPrimitive (HMAC p)'

Adding that to the type forces to use undecidableinstances which I dont want to use.

@satvikc
Copy link
Contributor Author

satvikc commented Aug 27, 2013

I have refactored the code but tests are failing. I am not sure where the bug is. But it is happening because of some garbage as the hash on the same string is giving different values each time.

@piyush-kurur
Copy link
Member

The interface is no more relevant I am closing this issue

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

No branches or pull requests

2 participants