Skip to content

Commit 2ef242e

Browse files
committed
Change the way ID packets are represented
1 parent a4a351d commit 2ef242e

5 files changed

Lines changed: 13 additions & 16 deletions

File tree

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 1.3.0
2+
3+
*2021-08-05*
4+
5+
### Changed
6+
7+
- Change the way ID packets are represented in the PGP module
8+
19
## 1.2.1
210

311
*2021-07-30*

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Parsers for PGP (Pretty Good Privacy) encodings of DSA, RSA and Elgamal Public a
3131
Private keys and user IDs as defined in [RFC 4880] (https://datatracker.ietf.org/doc/html/rfc4880)
3232
Note that the parsers in this module expect raw byte string. They don't handle PEM armoring
3333
nor decode Base64 or hex.
34+
This module is experimental.
3435

3536
### `Ltpa`
3637

lib/pgp.ml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,9 @@ module Packet = struct
340340
end
341341

342342
module Id = struct
343-
type t =
344-
{ name : string
345-
; email : string }
346-
[@@deriving ord, eq, show]
343+
type t = string [@@deriving ord, eq, show]
347344

348-
let decode cs =
349-
let id = Cstruct.to_string cs in
350-
let sep_id = String.split_on_char '<' id in
351-
let name = String.concat "<" (List.rev (List.tl (List.rev sep_id))) in
352-
let email = List.nth sep_id (List.length sep_id - 1) in
353-
{name; email = String.sub email 0 (String.length email - 1)}
345+
let decode cs = Cstruct.to_string cs
354346
end
355347

356348
module Public_key = struct

lib/pgp.mli

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ module Packet : sig
148148
end
149149

150150
module Id : sig
151-
type t =
152-
{ name : string
153-
; email : string }
154-
[@@deriving ord, eq, show]
151+
type t = string [@@deriving ord, eq, show]
155152

156153
val decode : Cstruct.t -> t
157154
end

tests/test_pgp.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ module Elgamal = struct
199199
let suite = ["Public" >:: test_public]
200200
end
201201

202-
let id_packet =
203-
Packet.Body.Id Packet.Id.{name = "Clement "; email = "clement@test"}
202+
let id_packet = Packet.Body.Id "Clement <clement@test>"
204203

205204
module Test_errors = struct
206205
let test_rsa_tag0 ctxt =

0 commit comments

Comments
 (0)