git: 9f526a5a763e - main - security/ocaml-cryptgps: ease transition to post-4.06 OCaml
Alexey Dokuchaev
danfe at FreeBSD.org
Wed Sep 8 08:03:25 UTC 2021
The branch main has been updated by danfe:
URL: https://cgit.FreeBSD.org/ports/commit/?id=9f526a5a763e7eb97fe9d039b40b6fa54c806852
commit 9f526a5a763e7eb97fe9d039b40b6fa54c806852
Author: Alexey Dokuchaev <danfe at FreeBSD.org>
AuthorDate: 2021-09-08 08:02:22 +0000
Commit: Alexey Dokuchaev <danfe at FreeBSD.org>
CommitDate: 2021-09-08 08:02:23 +0000
security/ocaml-cryptgps: ease transition to post-4.06 OCaml
- Use appropriate data type (Bytes) for mutable strings
- Provide more elaborate port description while I'm here
Obtained from: Debian
---
security/ocaml-cryptgps/files/patch-crypt__des.ml | 17 ++
.../ocaml-cryptgps/files/patch-cryptmodes__64.ml | 234 +++++++++++++++++++++
security/ocaml-cryptgps/pkg-descr | 4 +-
3 files changed, 254 insertions(+), 1 deletion(-)
diff --git a/security/ocaml-cryptgps/files/patch-crypt__des.ml b/security/ocaml-cryptgps/files/patch-crypt__des.ml
new file mode 100644
index 000000000000..15a5395f51e0
--- /dev/null
+++ b/security/ocaml-cryptgps/files/patch-crypt__des.ml
@@ -0,0 +1,17 @@
+--- crypt_des.ml.orig 2001-03-10 16:43:21 UTC
++++ crypt_des.ml
+@@ -54,12 +54,12 @@ let set_parity key =
+ let l_key = String.length key in
+ if l_key <> 8 then
+ failwith "Crypt_des: invalid key length";
+- let key' = String.copy key in
++ let key' = Bytes.of_string key in
+ for i = 0 to 7 do
+ let k = Char.code key.[i] in
+ key'.[i] <- Char.chr(odd_parity.(k))
+ done;
+- key'
++ Bytes.to_string key'
+ ;;
+
+
diff --git a/security/ocaml-cryptgps/files/patch-cryptmodes__64.ml b/security/ocaml-cryptgps/files/patch-cryptmodes__64.ml
new file mode 100644
index 000000000000..75cb3c25200b
--- /dev/null
+++ b/security/ocaml-cryptgps/files/patch-cryptmodes__64.ml
@@ -0,0 +1,234 @@
+--- cryptmodes_64.ml.orig 2001-03-10 16:43:21 UTC
++++ cryptmodes_64.ml
+@@ -52,7 +52,7 @@ module Make_modes (M : Cryptsystem_64.T) =
+ if l mod 8 <> 0 then failwith "encrypt_cbc";
+
+ let n = l / 8 in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let v = ref iv in
+ for i = 0 to n-1 do
+@@ -79,7 +79,7 @@ module Make_modes (M : Cryptsystem_64.T) =
+ data'.[j+7] <- Char.chr(v0' land 0xff);
+ done;
+
+- !v, data'
++ !v, Bytes.to_string data'
+
+
+ let decrypt_cbc k iv data =
+@@ -87,7 +87,7 @@ module Make_modes (M : Cryptsystem_64.T) =
+ if l mod 8 <> 0 then failwith "decrypt_cbc";
+
+ let n = l / 8 in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let v = ref iv in
+ for i = 0 to n-1 do
+@@ -119,12 +119,12 @@ module Make_modes (M : Cryptsystem_64.T) =
+ v := (x3,x2,x1,x0);
+ done;
+
+- !v, data'
++ !v, Bytes.to_string data'
+
+
+ let encrypt_cfb8 k iv data =
+ let l = String.length data in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let sr = ref iv in (* shift register *)
+
+@@ -139,12 +139,12 @@ module Make_modes (M : Cryptsystem_64.T) =
+ ((sr0 lsl 8) land 0xff00) lor c);
+ done;
+
+- !sr, data'
++ !sr, Bytes.to_string data'
+
+
+ let decrypt_cfb8 k iv data =
+ let l = String.length data in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let sr = ref iv in (* shift register *)
+
+@@ -160,7 +160,7 @@ module Make_modes (M : Cryptsystem_64.T) =
+ ((sr0 lsl 8) land 0xff00) lor c);
+ done;
+
+- !sr, data'
++ !sr, Bytes.to_string data'
+
+
+ let array_of_quadrupel (n3,n2,n1,n0) =
+@@ -182,7 +182,7 @@ module Make_modes (M : Cryptsystem_64.T) =
+ let encrypt_cfb64 k iv j data =
+ if j < 0 or j > 7 then failwith "encrypt_cfb64";
+ let l = String.length data in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let sr_a = ref (array_of_quadrupel iv) in
+ let jc = ref j in
+@@ -200,13 +200,13 @@ module Make_modes (M : Cryptsystem_64.T) =
+ done;
+
+ let sr = quadrupel_of_array !sr_a in
+- sr, !jc, data'
++ sr, !jc, Bytes.to_string data'
+
+
+ let decrypt_cfb64 k iv j data =
+ if j < 0 or j > 7 then failwith "decrypt_cfb64";
+ let l = String.length data in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let sr_a = ref (array_of_quadrupel iv) in
+ let jc = ref j in
+@@ -224,13 +224,13 @@ module Make_modes (M : Cryptsystem_64.T) =
+ done;
+
+ let sr = quadrupel_of_array !sr_a in
+- sr, !jc, data'
++ sr, !jc, Bytes.to_string data'
+
+
+ let crypt_ofb k iv j data =
+ if j < 0 or j > 7 then failwith "crypt_ofb";
+ let l = String.length data in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let sr_a = ref (array_of_quadrupel iv) in
+ let jc = ref j in
+@@ -247,7 +247,7 @@ module Make_modes (M : Cryptsystem_64.T) =
+ done;
+
+ let sr = quadrupel_of_array !sr_a in
+- sr, !jc, data'
++ sr, !jc, Bytes.to_string data'
+
+ end
+ ;;
+@@ -263,7 +263,7 @@ module Make_modes_int32 (M : Cryptsystem_64.T) =
+ if l mod 8 <> 0 then failwith "encrypt_cbc";
+
+ let n = l / 8 in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let vl = ref Int32.zero in
+ let vr = ref Int32.zero in
+@@ -308,7 +308,7 @@ module Make_modes_int32 (M : Cryptsystem_64.T) =
+ data'.[j+7] <- Char.chr(v0' land 0xff);
+ done;
+
+- quadruple_of_int32 !vl !vr, data'
++ quadruple_of_int32 !vl !vr, Bytes.to_string data'
+
+
+ let decrypt_cbc k iv data =
+@@ -316,7 +316,7 @@ module Make_modes_int32 (M : Cryptsystem_64.T) =
+ if l mod 8 <> 0 then failwith "decrypt_cbc";
+
+ let n = l / 8 in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let vl = ref Int32.zero in
+ let vr = ref Int32.zero in
+@@ -367,12 +367,12 @@ module Make_modes_int32 (M : Cryptsystem_64.T) =
+ vr := xr;
+ done;
+
+- quadruple_of_int32 !vl !vr, data'
++ quadruple_of_int32 !vl !vr, Bytes.to_string data'
+
+
+ let encrypt_cfb8 k iv data =
+ let l = String.length data in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let sr_l = ref Int32.zero in (* shift register MSB *)
+ let sr_r = ref Int32.zero in (* shift register LSB *)
+@@ -396,12 +396,12 @@ module Make_modes_int32 (M : Cryptsystem_64.T) =
+ (Int32.of_int c)
+ done;
+
+- quadruple_of_int32 !sr_l !sr_r, data'
++ quadruple_of_int32 !sr_l !sr_r, Bytes.to_string data'
+
+
+ let decrypt_cfb8 k iv data =
+ let l = String.length data in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let sr_l = ref Int32.zero in (* shift register MSB *)
+ let sr_r = ref Int32.zero in (* shift register LSB *)
+@@ -426,7 +426,7 @@ module Make_modes_int32 (M : Cryptsystem_64.T) =
+ (Int32.of_int c)
+ done;
+
+- quadruple_of_int32 !sr_l !sr_r, data'
++ quadruple_of_int32 !sr_l !sr_r, Bytes.to_string data'
+
+
+ let mask =
+@@ -439,7 +439,7 @@ module Make_modes_int32 (M : Cryptsystem_64.T) =
+ let encrypt_cfb64 k iv j data =
+ if j < 0 or j > 7 then failwith "encrypt_cfb64";
+ let l = String.length data in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let sr_l = ref Int32.zero in (* shift register MSB *)
+ let sr_r = ref Int32.zero in (* shift register LSB *)
+@@ -479,13 +479,13 @@ module Make_modes_int32 (M : Cryptsystem_64.T) =
+ jc := (!jc + 1) mod 8;
+ done;
+
+- quadruple_of_int32 !sr_l !sr_r, !jc, data'
++ quadruple_of_int32 !sr_l !sr_r, !jc, Bytes.to_string data'
+
+
+ let decrypt_cfb64 k iv j data =
+ if j < 0 or j > 7 then failwith "decrypt_cfb64";
+ let l = String.length data in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let sr_l = ref Int32.zero in (* shift register MSB *)
+ let sr_r = ref Int32.zero in (* shift register LSB *)
+@@ -525,13 +525,13 @@ module Make_modes_int32 (M : Cryptsystem_64.T) =
+ jc := (!jc + 1) mod 8;
+ done;
+
+- quadruple_of_int32 !sr_l !sr_r, !jc, data'
++ quadruple_of_int32 !sr_l !sr_r, !jc, Bytes.to_string data'
+
+
+ let crypt_ofb k iv j data =
+ if j < 0 or j > 7 then failwith "crypt_ofb";
+ let l = String.length data in
+- let data' = String.create l in
++ let data' = Bytes.create l in
+
+ let sr_l = ref Int32.zero in (* shift register MSB *)
+ let sr_r = ref Int32.zero in (* shift register LSB *)
+@@ -561,7 +561,7 @@ module Make_modes_int32 (M : Cryptsystem_64.T) =
+ jc := (!jc + 1) mod 8;
+ done;
+
+- quadruple_of_int32 !sr_l !sr_r, !jc, data'
++ quadruple_of_int32 !sr_l !sr_r, !jc, Bytes.to_string data'
+
+ end
+ ;;
diff --git a/security/ocaml-cryptgps/pkg-descr b/security/ocaml-cryptgps/pkg-descr
index 2bd616af7f29..88dc292cb9dc 100644
--- a/security/ocaml-cryptgps/pkg-descr
+++ b/security/ocaml-cryptgps/pkg-descr
@@ -1,3 +1,5 @@
-This library implements Blowfish, DES, and Triple-DES.
+This OCaml library implements some well-known symmetric cryptographic
+algorithms, namely: Blowfish, DES, Triple-DES. This package contains
+all the development stuff needed to use cryptgps in OCaml programs.
WWW: http://www.ocaml-programming.de/packages/
More information about the dev-commits-ports-all
mailing list