cryptosense / key-parsers Goto Github PK
View Code? Open in Web Editor NEWOCaml parsers for multiple key formats
License: BSD 2-Clause "Simplified" License
OCaml parsers for multiple key formats
License: BSD 2-Clause "Simplified" License
Hi,
I updated key-parsers
to 0.6.0 and it seems that it creates an unusable installation:
ocamlfind ocamlc -c -g -package records -package ppx_deriving_yojson -package ppx_deriving.std -package key-parsers -package hex -package ctypes.stubs -package ctypes.foreign -I src -I include -o src/pkcs11_CK_ATTRIBUTE_TYPE.cmi src/pkcs11_CK_ATTRIBUTE_TYPE.mli
File "src/pkcs11_CK_ATTRIBUTE_TYPE.mli", line 67, characters 20-48:
Error: The module Key_parsers.Asn1 is an alias for module Kp_asn1, which is missing
Command exited with code 2.
Removing the ~api
parameter in pkg.ml
will work, but exposes Kp_asn1
too. If you wish you can release that as 0.6.1.
Note that you can include that as part of your CI by passing REVDEPS=pkcs11
in your env
matrix (doc).
✨ Thanks ✨
EC parameters (and other parts) serialize Cstruct values directly as plain strings. This does not work for binary data, because JSON strings represent Unicode data.
The following program displays the problem:
let ic = open_in path in
let len = in_channel_length ic in
let s = really_input_string ic len in
close_in ic;
Cstruct.of_string s
let () =
"tests/keys/p256v1_explicit_param.der"
|> read_cstruct
|> Key_parsers.Asn1.EC.Params.decode
|> Rresult.R.get_ok
|> Key_parsers.Asn1.EC.Params.to_yojson
|> Yojson.Safe.pretty_to_string
|> print_endline
This can be built as:
% ocamlfind ocamlopt -package key-parsers -package yojson -package rresult -linkpkg dump.ml
% ./a.out > out.json
% python3 -mjson.tool out.json
'utf-8' codec can't decode byte 0xff in position 180: invalid start byte
My suggestion is to use hex encoding prefixed with 0x
. A more space-efficient alternative is to use base64
but this makes the output JSON less readable, and EC parameters are usually bounded in size anyway.
I'm happy to provide a patch if that's good with you.
Thanks!
I think OCamlTLS has some parsing functions for keys and certificates, I've used them in my KMIP code. They use Cstruct as well so it should be useful for you.
See: ocaml/opam-repository#8777 for an upper bound placed on ppx_bin_prot due to a compilation failure of key-parsers.0.7
The migration and fix is described in janestreet/bin_prot#14 if you want to support the latest version of Core, which is being currently being tested for merge. Existing releases will not break in stable opam, since the upper bound placed ensures that they use the old ppx_bin_prot.
In 4.03 the following warning is emitted when key-parsers
is linked in:
Warning 58: no cmx file was found in path for module Key_parsers, and its interface was not compiled with -opaque
You can fix it either by adding true: opaque
or installing the .cmx files (preferred). topkg
will do this automatically if you want to give it a try :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.