-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base64: \n #78
Comments
Unable to reproduce the The Nocrypto implementation is equivalent to the encoding described in RFC 3548 (NOTE: not the "URL and Filename Safe Alphabet" flavor). RFC 3548 specifically forbids extraneous characters (such as newlines) and provides arguments against ignoring them. I agree that better documentation of these features in the interface would be nice to have - the current interface leaves a lot to speculation:
It does however provide the let src = Cstruct.of_string "a bcd\ne";;
(* val src : Cstruct.t = {Cstruct.buffer = <abstr>; off = 0; len = 7} *)
let i = Cstruct.iter
(*chunks of 1:*)
(fun _ -> Some 1)
(* convert the first char of each 1-byte cstruct to char and check if it's allowed: *)
(fun cstr -> cstr, Cstruct.get_char cstr 0 |> Nocrypto.Base64.is_base64_char) src;;
(* val i : (Cstruct.t * bool) Cstruct.iter = <fun> *)
let filtered = Cstruct.fold
(fun acc ->
function (c,true) -> Cstruct.append acc c | _ -> acc)
i Cstruct.(create 0);;
(* val filtered : Cstruct.t = {Cstruct.buffer = <abstr>; off = 0; len = 5} *)
let final = Cstruct.to_string filtered;;
(* val final : string = "abcde" *) |
I am trying to match encoding and decoding responses to that of openssl on this matter and it seems to throw Invalid_Argument when decoding.
The openssl cmd tool returns a new line after every 64 characters and I am just wondering if there is a way to get around this? (or maybe I missed something?)
Thank you!
The text was updated successfully, but these errors were encountered: