Skip to content

Instantly share code, notes, and snippets.

@zbroyar
Created March 8, 2011 21:02
Show Gist options
  • Save zbroyar/861046 to your computer and use it in GitHub Desktop.
Save zbroyar/861046 to your computer and use it in GitHub Desktop.
PKCS#1 ver 1 padding
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