https://github.com/quadule/digest-cmac
A Ruby implementation of the CMAC digest algorithm, based on RFC 4493
https://github.com/quadule/digest-cmac
Last synced: 10 months ago
JSON representation
A Ruby implementation of the CMAC digest algorithm, based on RFC 4493
- Host: GitHub
- URL: https://github.com/quadule/digest-cmac
- Owner: quadule
- Created: 2009-04-19T20:37:39.000Z (about 17 years ago)
- Default Branch: master
- Last Pushed: 2011-10-11T21:32:22.000Z (over 14 years ago)
- Last Synced: 2025-03-30T17:11:46.540Z (about 1 year ago)
- Language: Ruby
- Homepage:
- Size: 92.8 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
A Ruby implementation of the CMAC / OMAC1 digest algorithm, based on RFC 4493:
http://tools.ietf.org/html/rfc4493
Here's an example using a test vector from the RFC:
# key is 128 bits
key = ["2b7e151628aed2a6abf7158809cf4f3c"].pack('H*')
cmac = Digest::CMAC.new(OpenSSL::Cipher::Cipher.new('aes-128-cbc'), key)
cmac.update(["6bc1bee22e409f96e93d7e117393172a"].pack('H*'))
digest = cmac.digest
# unpack it into hex
digest.unpack('H*')[0] # => '070a16b46b4d4144f79bdd9dd04a287c'