File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ module type Dh = sig
38
38
type secret
39
39
val secret_of_octets : ?compress : bool -> string ->
40
40
(secret * string , error ) result
41
+ val secret_to_octets : secret -> string
41
42
val gen_key : ?compress : bool -> ?g : Mirage_crypto_rng .g -> unit ->
42
43
secret * string
43
44
val key_exchange : secret -> string -> (string , error ) result
@@ -505,6 +506,9 @@ module Make_dh (Param : Parameters) (P : Point) (S : Scalar) : Dh = struct
505
506
| Ok p -> Ok (p, share ?compress p)
506
507
| Error _ as e -> e
507
508
509
+ let secret_to_octets s =
510
+ S. to_octets s
511
+
508
512
let rec generate_private_key ?g () =
509
513
let candidate = Mirage_crypto_rng. generate ?g Param. byte_length in
510
514
match S. of_octets candidate with
@@ -953,6 +957,8 @@ module X25519 = struct
953
957
else
954
958
Error `Invalid_length
955
959
960
+ let secret_to_octets s = s
961
+
956
962
let is_zero =
957
963
let zero = String. make key_len '\000' in
958
964
fun buf -> String. equal zero buf
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ module type Dh = sig
38
38
the shared part will be compressed. May result in an error if the buffer
39
39
had an invalid length or was not in bounds. *)
40
40
41
+ val secret_to_octets : secret -> string
42
+ (* * [secret_to_octets secret] encodes the provided secret into a freshly
43
+ allocated buffer. *)
44
+
41
45
val gen_key : ?compress : bool -> ?g : Mirage_crypto_rng .g -> unit ->
42
46
secret * string
43
47
(* * [gen_key ~compress ~g ()] generates a private and a public key for
You can’t perform that action at this time.
0 commit comments