Skip to content

Commit f187b68

Browse files
Fix clippy warnings
1 parent c79bfc2 commit f187b68

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

core/src/mechanisms.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub trait Aes256Cbc: CryptoClient {
2929
wrapping_key,
3030
key,
3131
&[],
32-
iv.and_then(|iv| ShortData::try_from(iv).ok()),
32+
iv.map(ShortData::from),
3333
)
3434
}
3535
}
@@ -66,7 +66,7 @@ pub trait Chacha8Poly1305: CryptoClient {
6666
key,
6767
message,
6868
associated_data,
69-
nonce.and_then(|nonce| ShortData::try_from(nonce).ok()),
69+
nonce.map(ShortData::from),
7070
)
7171
}
7272

@@ -109,7 +109,7 @@ pub trait Chacha8Poly1305: CryptoClient {
109109
wrapping_key,
110110
key,
111111
associated_data,
112-
nonce.and_then(|nonce| ShortData::try_from(nonce).ok()),
112+
nonce.map(ShortData::from),
113113
)
114114
}
115115
}

src/mechanisms/chacha8poly1305.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ impl MechanismImpl for super::Chacha8Poly1305 {
152152
.try_into()
153153
.unwrap();
154154

155-
let nonce = ShortData::try_from(&nonce).unwrap();
156-
let tag = ShortData::try_from(&tag).unwrap();
155+
let nonce = ShortData::from(&nonce);
156+
let tag = ShortData::from(&tag);
157157

158158
// let ciphertext = Message::from_slice(&ciphertext).unwrap();
159159
Ok(reply::Encrypt {

src/mechanisms/ed255.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl MechanismImpl for super::Ed255 {
132132
let cose_pk = cosey::Ed25519PublicKey {
133133
// x: Bytes::from_slice(public_key.x_coordinate()).unwrap(),
134134
// x: Bytes::from_slice(&buf).unwrap(),
135-
x: Bytes::try_from(public_key.as_bytes()).unwrap(),
135+
x: Bytes::from(public_key.as_bytes()),
136136
};
137137
crate::cbor_serialize_bytes(&cose_pk).map_err(|_| Error::CborError)?
138138
}
@@ -187,7 +187,7 @@ impl MechanismImpl for super::Ed255 {
187187
let keypair = load_keypair(keystore, &key_id)?;
188188

189189
let native_signature = keypair.sign(&request.message);
190-
let our_signature = Signature::try_from(&native_signature.to_bytes()).unwrap();
190+
let our_signature = Signature::from(&native_signature.to_bytes());
191191

192192
// hprintln!("Ed255 signature:").ok();
193193
// hprintln!("msg: {:?}", &request.message).ok();

src/mechanisms/p256.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,15 @@ impl MechanismImpl for super::P256 {
205205
let serialized_key = match request.format {
206206
KeySerialization::EcdhEsHkdf256 => {
207207
let cose_pk = cosey::EcdhEsHkdf256PublicKey {
208-
x: Bytes::try_from(&public_key.x()).unwrap(),
209-
y: Bytes::try_from(&public_key.y()).unwrap(),
208+
x: Bytes::from(&public_key.x()),
209+
y: Bytes::from(&public_key.y()),
210210
};
211211
crate::cbor_serialize_bytes(&cose_pk).map_err(|_| Error::CborError)?
212212
}
213213
KeySerialization::Cose => {
214214
let cose_pk = cosey::P256PublicKey {
215-
x: Bytes::try_from(&public_key.x()).unwrap(),
216-
y: Bytes::try_from(&public_key.y()).unwrap(),
215+
x: Bytes::from(&public_key.x()),
216+
y: Bytes::from(&public_key.y()),
217217
};
218218
crate::cbor_serialize_bytes(&cose_pk).map_err(|_| Error::CborError)?
219219
}
@@ -270,7 +270,7 @@ impl MechanismImpl for super::P256 {
270270
Signature::try_from(&buffer[..l]).unwrap()
271271
}
272272
SignatureSerialization::Raw => {
273-
Signature::try_from(&signature.to_untagged_bytes()).unwrap()
273+
Signature::from(&signature.to_untagged_bytes())
274274
}
275275
_ => {
276276
return Err(Error::InvalidSerializationFormat);
@@ -355,7 +355,7 @@ impl MechanismImpl for super::P256Prehashed {
355355
Signature::try_from(&buffer[..l]).unwrap()
356356
}
357357
SignatureSerialization::Raw => {
358-
Signature::try_from(&signature.to_untagged_bytes()).unwrap()
358+
Signature::from(&signature.to_untagged_bytes())
359359
}
360360
_ => {
361361
return Err(Error::InvalidSerializationFormat);

0 commit comments

Comments
 (0)