summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMartin Thomson <mt@lowentropy.net>2021-03-17 15:03:04 +1100
committerMartin Thomson <mt@lowentropy.net>2021-03-17 15:03:04 +1100
commit53861aa080279334f4f30ef149622a06917466de (patch)
tree31b560911e82d2c0f516a69b8ad91d78b4d3d72e /cmd
parentf8a1612ec23452218d4f416eb2780b1a87597f3a (diff)
downloadnss-hg-53861aa080279334f4f30ef149622a06917466de.tar.gz
Bug 1698419 - ECH -10 updates, r=bbeurdouche
The main changes here are: * an update to HPKE -08 * a move to the single-byte configuration ID * reordering of ECHConfig The addition of the explicit configuration ID means that the API for constructing ECHConfig(List) needs to change. That means a name change, unfortunately. I took the opportunity to make further changes to the arguments. Differential Revision: https://phabricator.services.mozilla.com/D108392
Diffstat (limited to 'cmd')
-rw-r--r--cmd/selfserv/selfserv.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/cmd/selfserv/selfserv.c b/cmd/selfserv/selfserv.c
index 6b6f53a35..00de3a6b7 100644
--- a/cmd/selfserv/selfserv.c
+++ b/cmd/selfserv/selfserv.c
@@ -1894,16 +1894,23 @@ configureEchWithPublicName(PRFileDesc *model_sock, const char *public_name)
SECKEYPrivateKey *privKey = NULL;
SECOidData *oidData;
char *echConfigBase64 = NULL;
+ PRUint8 configId = 0;
PRUint8 configBuf[1000];
unsigned int len = 0;
- unsigned int echCipherSuite = ((unsigned int)HpkeKdfHkdfSha256 << 16) |
- HpkeAeadChaCha20Poly1305;
+ HpkeSymmetricSuite echCipherSuite = { HpkeKdfHkdfSha256,
+ HpkeAeadChaCha20Poly1305 };
+
PK11SlotInfo *slot = PK11_GetInternalKeySlot();
if (!slot) {
errWarn("PK11_GetInternalKeySlot failed");
return SECFailure;
}
+ if (PK11_GenerateRandom(&configId, sizeof(configId)) != SECSuccess) {
+ errWarn("Failed to generate random configId");
+ goto loser;
+ }
+
oidData = SECOID_FindOIDByTag(SEC_OID_CURVE25519);
if (oidData && (2 + oidData->oid.len) < sizeof(paramBuf)) {
ecParams.data[0] = SEC_ASN1_OBJECT_ID;
@@ -1916,16 +1923,17 @@ configureEchWithPublicName(PRFileDesc *model_sock, const char *public_name)
}
privKey = PK11_GenerateKeyPair(slot, CKM_EC_KEY_PAIR_GEN, &ecParams,
&pubKey, PR_FALSE, PR_FALSE, NULL);
-
if (!privKey || !pubKey) {
errWarn("Failed to generate ECH keypair");
goto loser;
}
- rv = SSL_EncodeEchConfig(echParamsStr, &echCipherSuite, 1,
- HpkeDhKemX25519Sha256, pubKey, 50,
- configBuf, &len, sizeof(configBuf));
+
+ rv = SSL_EncodeEchConfigId(configId, echParamsStr, 100,
+ HpkeDhKemX25519Sha256, pubKey,
+ &echCipherSuite, 1,
+ configBuf, &len, sizeof(configBuf));
if (rv != SECSuccess) {
- errWarn("SSL_EncodeEchConfig failed");
+ errWarn("SSL_EncodeEchConfigId failed");
goto loser;
}