Skip to content

Commit

Permalink
Adjusted to not mix programming paradigms.
Browse files Browse the repository at this point in the history
Fixes issue trustoverip#39.
  • Loading branch information
daidoji committed May 15, 2024
1 parent 9e58c02 commit 1b36cbd
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions spec/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1b36cbd

Please sign in to comment.