Skip to content

Commit cebeec9

Browse files
committed
Allow some known expects in the HPKE code
1 parent 6f2211c commit cebeec9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/hpke/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ impl Role {
207207
Role::Recipient { context, .. } => context.export(info.as_bytes(), &mut bytes),
208208
};
209209

210-
ret.expect("We should be able to foo");
210+
#[allow(clippy::expect_used)]
211+
ret.expect("We should be able to generate a check code, as it's just two bytes");
211212

212213
CheckCode { bytes }
213214
}
@@ -252,12 +253,14 @@ impl HpkeSenderChannel {
252253

253254
let Self { application_info_prefix } = self;
254255

256+
#[allow(clippy::expect_used)]
255257
let their_key =
256258
<X25519HkdfSha256 as hpke::Kem>::PublicKey::from_bytes(their_public_key.as_bytes())
257259
.expect(
258260
"Converting the Dalek public key to the HPKE public key should always work",
259261
);
260262

263+
#[allow(clippy::expect_used)]
261264
let (encapsulated_key, mut context): (_, SenderContext) = hpke::setup_sender(
262265
&OpModeS::Base,
263266
&their_key,
@@ -266,12 +269,14 @@ impl HpkeSenderChannel {
266269
)
267270
.expect("Encapsulating an X25519 public key never fails since the encapsulation is just the bytes of the public key");
268271

272+
#[allow(clippy::expect_used)]
269273
let ciphertext = context
270274
.seal(initial_plaintext, &[])
271275
.expect("We should be able to seal the initial plaintext");
272276
let response_context = context.response_context();
273277

274278
let encapsulated_key = encapsulated_key.to_bytes();
279+
#[allow(clippy::expect_used)]
275280
let encapsulated_key = Curve25519PublicKey::from_slice(encapsulated_key.as_slice()).expect(
276281
"Converting from the HPKE public key to the Dalek public key should always work",
277282
);
@@ -325,13 +330,15 @@ impl HpkeRecipientChannel {
325330
let their_public_key = message.encapsulated_key;
326331
let our_public_key = Curve25519PublicKey::from(&secret_key);
327332

333+
#[allow(clippy::expect_used)]
328334
let secret_key = <X25519HkdfSha256 as hpke::Kem>::PrivateKey::from_bytes(
329335
secret_key.as_bytes(),
330336
)
331337
.expect(
332338
"Converting from our PrivateKey type to the HPKE private key type should never fail",
333339
);
334340

341+
#[allow(clippy::expect_used)]
335342
let encapped_key = <X25519HkdfSha256 as hpke::Kem>::EncappedKey::from_bytes(
336343
message.encapsulated_key.as_bytes(),
337344
)
@@ -427,6 +434,7 @@ impl EstablishedHpkeChannel {
427434
Role::Recipient { response_context, .. } => response_context.seal(plaintext, &[]),
428435
};
429436

437+
#[allow(clippy::expect_used)]
430438
let ciphertext = ret.expect(
431439
"We should be able to seal a plaintext, unless we're overflowed the sequence counter",
432440
);

0 commit comments

Comments
 (0)