-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide 'sign' and 'verify' to secure cookies with HMAC
The two functions are very basic and provide a layer of security for cookies. - sign cookies with HMAC given a cookie, checksum type and secret key - verify a previously signed cookie using the same checksum type and secret key The computed signature is: HMAC(checksum_type, key, HMAC(checksum_type, key, value) + name) + value It guarantees that we have produced the value and associated it with a name, which are the only data sent back by the user agent. It's up to the developer to decide what hash algorithm to use and how to handle its secret key. The reverse procedure firstly check the length of a signature using checksum_type on an arbitrary string so that it can extract the checksum from the value without the need of any separator. Add tests to handle specific cases: - signing an empty cookie - signing and verifying - verifying a cookie - verifying a too small signature Add documentation to cover 'sign' and 'verify' processes. fixup
- Loading branch information
Showing
4 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters