Created
March 8, 2011 21:02
-
-
Save zbroyar/861046 to your computer and use it in GitHub Desktop.
PKCS#1 ver 1 padding
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
let pkcs1v1pad key msg = | |
let blen = key.RSA.size/8 | |
and mlen = String.length msg in | |
let padlen = blen - mlen in | |
if padlen > 3 then begin | |
let res = String.make padlen (char_of_int 255) in | |
res.[0] <- (char_of_int 0); | |
res.[1] <- (char_of_int 1); | |
res.[padlen - 1] <- (char_of_int 0); | |
res ^ msg | |
end | |
else msg | |
;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment