Security and Cryptography
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationSecurity and Cryptography
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.

Learn More!


Download to Enter
| Contest Rules

Tutorials | Forums

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 8th, 2012, 05:58 AM
wise.man wise.man is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 10 wise.man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 57 m 28 sec
Reputation Power: 0
How to use an HMAC?

i am using a cryptographic library in php (http://phpseclib.sourceforge.net/).

i am adding a new pair of methods to its AES class.
those methods implement HMAC generation/verification.
encryption method adds the hmac string to the ciphertext.
decryption method separates the hmac and verifies it.

i have several questions.

1) is this general formula correct for the encryption method:

Code:
ciphertext=aes_encr(key, plaintext)
final_result=hmac(key, ciphertext)||ciphertext

note: || means concatenation.

2) it is better the hmac be appended or prepended to the cipher text and why (or maybe there is no deference?).

3) i can use a variety of hash algorithms for hmac:
md2, md5, md5-96, sha1, sha1-96, sha256, sha384, and sha512

but i dont want to degrade the performance and increase the output length unnecessarily. if it is relevant, i use AES 128 bits; i am not sure if there must be a correlation between the encryption key length and the hmac algorithm used.

i know that the md5 and sha1 hash algorithms have known weaknesses and should no longer be used, but wikipedia article about HMAC says:
Quote:
HMACs are substantially less affected by collisions than their underlying hashing algorithms alone.[5] [6] .[7] Therefore, HMAC-MD5 does not suffer from the same weaknesses that have been found in MD5.

so can i use hmac-md5 safely?

Reply With Quote
  #2  
Old January 21st, 2012, 04:12 PM
ehmicky ehmicky is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2012
Posts: 3 ehmicky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 14 m 36 sec
Reputation Power: 0
Hi,
For question 2, I'm trying to think about it, but I don't see why the place of the MAC should matter. Indeed, you can let any eavedropper guess where is your MAC and where is your ciphertext inside final_result, if your MAC and ciphertext are safe. It can be a public information, so whether the MAC is behind the ciphertext or not doesn't seem to be an issue for me.
Also, I'd like to add to your question :
4) Is it safe to use the same key for the symetric cipher (aes_encr) and the HMAC (as you do) ? I know it's not when using CBC-MAC, but I wonder if it's also the case for HMAC.

Reply With Quote
  #3  
Old March 7th, 2012, 04:42 AM
jacksena jacksena is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 1 jacksena User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 23 sec
Reputation Power: 0
Well i am not sure about this but you can take mac support for better information such as any Mac related issue.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationSecurity and Cryptography > How to use an HMAC?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap