티스토리 뷰
A keyed-hash message authentication code, or HMAC, is a type of message authentication code (MAC) calculated using a cryptographic hash function in combination with a secret key. As with any MAC, it may be used to simultaneously verify both the data integrity and the authenticity of a message. Any iterative cryptographic hash function, such as MD5 or SHA-1, may be used in the calculation of an HMAC; the resulting MAC algorithm is termed HMAC-MD5 or HMAC-SHA-1 accordingly. The cryptographic strength of the HMAC depends upon the cryptographic strength of the underlying hash function, on the size and quality of the key and the size of the hash output length in bits.
An iterative hash function breaks up a message into blocks of a fixed size and iterates over them with a compression function. For example, MD5 and SHA-1 operate on 512-bit blocks. The size of the output of HMAC is the same as that of the underlying hash function (128 or 160 bits in the case of MD5 and SHA-1), although it can be truncated if desired. Truncating the hash image reduces the security of the MAC which is upper bound by the birthday attack.
The construction and analysis of HMACs was first published in 1996 by Mihir Bellare, Ran Canetti, and Hugo Krawczyk, who also wrote RFC 2104. FIPS PUB 198 generalizes and standardizes the use of HMACs. HMAC-SHA-1 and HMAC-MD5 are used within the IPsec and TLS protocols.
Contents[hide] |
[edit] Definition
where h is an iterated hash function, K is a secret key padded with extra zeros to the block size of the hash function, m is the message to be authenticated, denotes concatenation, denotes exclusive or, and the outer padding and inner padding are two one-block–long hexadecimal constants.
[edit] Implementation
The following pseudocode demonstrates how HMAC may be implemented.
function hmac (key, message) opad = [0x5c * blocksize] // Where blocksize is that of the underlying hash function ipad = [0x36 * blocksize] if (length(key) > blocksize) then key = hash(key) // Where 'hash' is the underlying hash function end if for i from 0 to length(key) step 1 ipad[i] = ipad[i] XOR key[i] opad[i] = opad[i] XOR key[i] end for return hash(opad || hash(ipad || message)) // Where || is concatenation end function
[edit] Example usage
A pizza restaurant that suffers from attackers that place bogus Internet orders may insist that all its customers deposit a secret key with the restaurant. Along with an order, a customer must supply the order's HMAC digest, computed using the customer's secret key. The restaurant, knowing the customer's secret key, can then verify that the order originated from the stated customer and has not been tampered with.
[edit] Security
The cryptographic strength of the HMAC depends upon the cryptographic strength of the underlying hash function, on the size and quality of the key and the size of the hash output length in bits. As outlined in "Keying Hash Functions for Message Authentication", MACs can be vulnerable to birthday, collision, extension, and other attacks.
In the recently (2006) published paper "On the Security of HMAC and NMAC Based on HAVAL, MD4, MD5, SHA-0 and SHA-1", by Jongsung Kim, Alex Biryukov, Bart Preneel, Seokhie Hong, claim to have devised: "two new distinguishers of the structure of HMAC, called differential and rectangle distinguishers, and use them to discuss the security of HMAC based on HAVAL, MD4, MD5, SHA-0 and SHA-1. We show how to distinguish HMAC with reduced or full versions of these cryptographic hash functions from a random function or from HMAC with a random function. We also show how to use our differential distinguisher to devise a forgery attack on HMAC. Our distinguishing and forgery attacks can also be mounted on NMAC based on HAVAL, MD4, MD5, SHA-0 and SHA-1. Furthermore, we show that our differential and rectangle distinguishers can lead to second-preimage attacks on HMAC and NMAC.". They go on to claim: "With these distinguishing and forgery attacks we have shown that HMAC with the full versions of 3-pass HAVAL and SHA-0 can be distinguished from HMAC with a random function, and HMAC with the full version of MD4 can be forged. These distinguishing and forgery attacks have also been applied to HMAC based on reduced versions of MD5 and SHA-1. All these attacks do not contradict the security proof of HMAC, but they improve our understanding of the security of HMAC based on existing cryptographic hash functions."
[edit] External links
- RFC 2104, HMAC: Keyed-Hashing for Message Authentication
- RFC 2202, HMAC-MD5 and HMAC-SHA1 Test Vectors, HMAC-SHA1 implementation in C
- FIPS PUB 198, The Keyed-Hash Message Authentication Code
- HMAC Algorithm in Detail
- Python HMAC implementation
- An introduction to HMAC
[edit] References
- Mihir Bellare, Ran Canetti and Hugo Krawczyk, Keying Hash Functions for Message Authentication, CRYPTO 1996, pp1–15 (PS or PDF).
- Mihir Bellare, Ran Canetti and Hugo Krawczyk, Message authentication using hash functions: The HMAC construction, CryptoBytes 2(1), Spring 1996 (PS or PDF).
- Jongsung Kim, Alex Biryukov, Bart Preneel, Seokhie Hong, "On the Security of HMAC and NMAC Based on HAVAL, MD4, MD5, SHA-0 and SHA-1", 2006. (pdf)
Hash algorithms: Gost-Hash | HAS-160 | HAS-V | HAVAL | MDC-2 | MD2 | MD4 | MD5 | N-Hash | RadioGatún | RIPEMD | SHA family | Snefru | Tiger | VEST | WHIRLPOOL | crypt(3) DES |
MAC algorithms: DAA | CBC-MAC | HMAC | OMAC/CMAC | PMAC | UMAC | Poly1305-AES | VEST |
Authenticated encryption modes: CCM | EAX | GCM | OCB | VEST |
Attacks: Hash collision | Birthday attack | Collision attack | Preimage attack | Rainbow table | Brute force attack |
Standardization: CRYPTREC | NESSIE |
Misc: Avalanche effect | Hash collision | Hash functions based on block ciphers |
History of cryptography | Cryptanalysis | Cryptography portal | Topics in cryptography |
Symmetric-key algorithm | Block cipher | Stream cipher | Public-key cryptography | Cryptographic hash function | Message authentication code | Random numbers |
'보안 > 일반' 카테고리의 다른 글
NHN-KISA, 악성코드 은닉사이트 탐지 협력 (0) | 2007.07.06 |
---|---|
SSL인증서의 종류와 바로알기 (0) | 2007.07.06 |
HMAC: Keyed-Hashing for Message Authentication RFC 2104 (RFC2104) (0) | 2007.07.06 |
Birthday attack - From Wikipedia, the free encyclopedia (3) | 2007.07.06 |
Self-organized public-key management for mobile ad hoc networks (0) | 2007.07.06 |
- Total
- Today
- Yesterday
- 지루박멸연구센타
- 열정의 힘을 믿는다
- Le4rN TO Cr4cK
- 디버깅에관한모든것(DebugLab)
- sysinternals
- FoundStone
- hashtab
- 보안-coderant
- 디바이스드라이버 개발자 포럼
- dualpage.muz.ro
- osronline.com - 드라이버 관련 정보 사이트
- NtInternals - NativeAPI Refere…
- pcthreat - spyware 정보 제공
- rootkit.com - 루트킷 관련 정보
- www.ntinternals.net
- WINE CrossRef. - source.winehq…
- tuts4you
- hex-rays
- idapalace
- idefense
- immunityinc
- threatexpert
- hdp.null2root.org
- www.crackstore.com
- crackmes.de
- www.who.is
- www.cracklab.ru
- community.reverse-engineering.…
- video.reverse-engineering.net
- SnD
- 클레이 키위
- reversengineering.wordpress.co…
- www.openrce.org
- www.woodmann.com
- PEID.Plusins.BobSoft
- roxik.com/pictaps/
- regexlib.com
- spyware-browser.com
- www.usboffice.kr
- regulator
- www.txt2re.com
- ietab.mozdev.org
- zesrever.xstone.org
- www.heaventools.com/PE-file-he…
- www.heaventools.com
- www.innomp3.com
- 울지않는벌새
- exetools.com-forum
- exetools.com
- utf8 conv
- robtex - IP trace
- onsamehost - same IP sites
- JpopSuki
- jsunpack.jeek.org
- wepawet.iseclab.org
- www.jswiff.com
- www.hackeroo.com
- winesearcher.co.kr
- khpga.org
- malwareurl.com
- anubis.iseclab.org
- www.crummy.com-eautifulSoup
- malwarebytes.org/forums
- bbs.janmeng.com
- blackip.ustc.edu.cn
- eureka.cyber-ta.org
- exploit-db.com
- 신한저축은행
- 실시간트래이딩
- PIR
- 맥쿼리인프라
- 군함도
- logrotate
- hai
- 레고랜드
- 자동트래이딩
- INVOICE
- 주식트래이딩
- Pivot
- 사회간접자본
- ubuntu
- 주택구매력지수
- 매매가격지수
- 피봇
- O365
- ElasticSearch
- 주식
- ROA
- SBI저축은행
- 다올저축은행
- CriticalSection
- 전세매매지수
- 미국주식
- ChatGPT
- 시스템트래이딩
- 공공인프라
- systemd
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |