From 1b36cbd874b7549afef09b751ee82a550860c221 Mon Sep 17 00:00:00 2001 From: Charles Lanahan Date: Wed, 15 May 2024 10:34:07 -0400 Subject: [PATCH] Adjusted to not mix programming paradigms. Fixes issue #39. --- spec/spec.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/spec/spec.md b/spec/spec.md index ac0c780..69a946f 100644 --- a/spec/spec.md +++ b/spec/spec.md @@ -1052,45 +1052,46 @@ Libsodium is a popularly available open source software library that is a fork o Per [[spec-norm:libsodium]] documentation, the combined mode API defined in `C` is as follows. -``` text +``` c int crypto_box_seal(unsigned char *c, const unsigned char *m, unsigned long long mlen, const unsigned char *pk); ``` `crypto_box_seal()` encrypts plaintext `m` of length `mlen` using the receiver's public key `pk`, and outputs to buffer `c` the ciphertext. -``` text +``` c int crypto_box_seal_open(unsigned char *m, const unsigned char *c, unsigned long long clen, const unsigned char *pk, const unsigned char *sk); ``` `crypto_box_seal_open()` decrypts the ciphertext `c` of length `clen` using the sender's public key `pk` and the receiver's secret key `sk`, and outputs the plaintext to `m`. -##### TSP USE of Sealed Box for PKAE +##### TSP Use of Sealed Box for PKAE -To use sealed box as the PKAE in TSP, for TSP message that uses confidential payload, the ciphertext MUST generated by `crypto_box_seal()` API as follows or an equivalent procedure: +To use sealed box as the PKAE in TSP, for TSP message that uses confidential payload, the ciphertext MUST generated by `crypto_box_seal()` API as follows (in pseudocode) or an equivalent procedure: ``` text def TSP_SEAL(VID_sndr, VID_rcvr, Non_Confidential_Fields, Confidential_Fields_Plaintext): pkR = VID_rcvr.PK_e pt = Confidential_Fields_Plaintext - mlen = lengthof(pt) - crypto_box_seal(&ct, &pt, mlen, &pkR) - return ct + mlen = Length(pt) + ciphertext = crypto_box_seal(pt, mlen, pkR) + return ciphertext Ciphertext = TSP_SEAL(VID_sndr, VID_rcvr, Non_Confidential_Fields, Confidential_Fields_Plaintext) ``` -The receiver MUST use the corresponding `crypto_box_seal_open()` API or an equivalent procedure to decrypt: +The receiver MUST use the corresponding `crypto_box_seal_open()` API procedure or an equivalent to decrypt: ``` text def TSP_OPEN(VID_sndr, VID_rcvr, Non_Confidential_Fields, Confidential_Fields_Ciphertext): pkS = VID_sndr.PK_e skR = VID_rcvr.SK_e ct = Confidential_Fields_Ciphertext - clen = lengthof(ct) - crypto_box_seal_open(&output, &ct, clen, &pkS, &skR) + clen = Length(ct) + output = crypto_box_seal_open(ct, clen, pkS, skR) + return output Plaintext = TSP_OPEN(VID_sndr, VID_rcvr, Non_Confidential_Fields,