Skip to content

Commit f4d5094

Browse files
committed
Let encoding types be generic over lifetimes
1 parent 5a815a9 commit f4d5094

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

aws-lc-rs/src/agreement.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,14 @@ impl PrivateKey {
434434
}
435435
}
436436

437-
impl AsDer<EcPrivateKeyRfc5915Der> for PrivateKey {
437+
impl AsDer<EcPrivateKeyRfc5915Der<'static>> for PrivateKey {
438438
/// Serializes the key as a DER-encoded `ECPrivateKey` (RFC 5915) structure.
439439
///
440440
/// X25519 is not supported.
441441
///
442442
/// # Errors
443443
/// `error::Unspecified` if serialization failed.
444-
fn as_der(&self) -> Result<EcPrivateKeyRfc5915Der, Unspecified> {
444+
fn as_der(&self) -> Result<EcPrivateKeyRfc5915Der<'static>, Unspecified> {
445445
if AlgorithmID::X25519 == self.inner_key.algorithm().id {
446446
return Err(Unspecified);
447447
}
@@ -461,14 +461,14 @@ impl AsDer<EcPrivateKeyRfc5915Der> for PrivateKey {
461461
}
462462
}
463463

464-
impl AsBigEndian<EcPrivateKeyBin> for PrivateKey {
464+
impl AsBigEndian<EcPrivateKeyBin<'static>> for PrivateKey {
465465
/// Exposes the private key encoded as a big-endian fixed-length integer.
466466
///
467467
/// X25519 is not supported.
468468
///
469469
/// # Errors
470470
/// `error::Unspecified` if serialization failed.
471-
fn as_be_bytes(&self) -> Result<EcPrivateKeyBin, Unspecified> {
471+
fn as_be_bytes(&self) -> Result<EcPrivateKeyBin<'static>, Unspecified> {
472472
if AlgorithmID::X25519 == self.inner_key.algorithm().id {
473473
return Err(Unspecified);
474474
}
@@ -482,14 +482,14 @@ impl AsBigEndian<EcPrivateKeyBin> for PrivateKey {
482482
}
483483
}
484484

485-
impl AsBigEndian<Curve25519SeedBin> for PrivateKey {
485+
impl AsBigEndian<Curve25519SeedBin<'static>> for PrivateKey {
486486
/// Exposes the seed encoded as a big-endian fixed-length integer.
487487
///
488488
/// Only X25519 is supported.
489489
///
490490
/// # Errors
491491
/// `error::Unspecified` if serialization failed.
492-
fn as_be_bytes(&self) -> Result<Curve25519SeedBin, Unspecified> {
492+
fn as_be_bytes(&self) -> Result<Curve25519SeedBin<'static>, Unspecified> {
493493
if AlgorithmID::X25519 != self.inner_key.algorithm().id {
494494
return Err(Unspecified);
495495
}

aws-lc-rs/src/ec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ pub struct PublicKey {
126126
octets: Box<[u8]>,
127127
}
128128

129-
impl AsDer<EcPublicKeyX509Der> for PublicKey {
129+
impl AsDer<EcPublicKeyX509Der<'static>> for PublicKey {
130130
/// Provides the public key as a DER-encoded (X.509) `SubjectPublicKeyInfo` structure.
131131
/// # Errors
132132
/// Returns an error if the underlying implementation is unable to marshal the point.
133-
fn as_der(&self) -> Result<EcPublicKeyX509Der, Unspecified> {
133+
fn as_der(&self) -> Result<EcPublicKeyX509Der<'static>, Unspecified> {
134134
let ec_group = unsafe { LcPtr::new(EC_GROUP_new_by_curve_name(self.algorithm.id.nid()))? };
135135
let ec_point = unsafe { ec_point_from_bytes(&ec_group, self.as_ref())? };
136136
let ec_key = unsafe { LcPtr::new(EC_KEY_new())? };

aws-lc-rs/src/ec/key_pair.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,14 @@ impl Debug for PrivateKey<'_> {
285285
}
286286
}
287287

288-
impl AsBigEndian<EcPrivateKeyBin> for PrivateKey<'_> {
288+
impl AsBigEndian<EcPrivateKeyBin<'static>> for PrivateKey<'_> {
289289
/// Exposes the private key encoded as a big-endian fixed-length integer.
290290
///
291291
/// For most use-cases, `EcdsaKeyPair::to_pkcs8()` should be preferred.
292292
///
293293
/// # Errors
294294
/// `error::Unspecified` if serialization failed.
295-
fn as_be_bytes(&self) -> Result<EcPrivateKeyBin, Unspecified> {
295+
fn as_be_bytes(&self) -> Result<EcPrivateKeyBin<'static>, Unspecified> {
296296
unsafe {
297297
let buffer = ec::marshal_private_key_to_buffer(
298298
self.0.algorithm.id.private_key_size(),
@@ -303,12 +303,12 @@ impl AsBigEndian<EcPrivateKeyBin> for PrivateKey<'_> {
303303
}
304304
}
305305

306-
impl AsDer<EcPrivateKeyRfc5915Der> for PrivateKey<'_> {
306+
impl AsDer<EcPrivateKeyRfc5915Der<'static>> for PrivateKey<'_> {
307307
/// Serializes the key as a DER-encoded `ECPrivateKey` (RFC 5915) structure.
308308
///
309309
/// # Errors
310310
/// `error::Unspecified` if serialization failed.
311-
fn as_der(&self) -> Result<EcPrivateKeyRfc5915Der, Unspecified> {
311+
fn as_der(&self) -> Result<EcPrivateKeyRfc5915Der<'static>, Unspecified> {
312312
unsafe {
313313
let mut outp = null_mut::<u8>();
314314
let ec_key = ConstPointer::new(EVP_PKEY_get0_EC_KEY(*self.0.evp_pkey))?;

aws-lc-rs/src/ed25519.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ impl Drop for Ed25519KeyPair {
105105
/// The seed value for the `EdDSA` signature scheme using Curve25519
106106
pub struct Seed<'a>(&'a Ed25519KeyPair);
107107

108-
impl AsBigEndian<Curve25519SeedBin> for Seed<'_> {
108+
impl AsBigEndian<Curve25519SeedBin<'static>> for Seed<'_> {
109109
/// Exposes the seed encoded as a big-endian fixed-length integer.
110110
///
111111
/// For most use-cases, `EcdsaKeyPair::to_pkcs8()` should be preferred.
112112
///
113113
/// # Errors
114114
/// `error::Unspecified` if serialization failed.
115-
fn as_be_bytes(&self) -> Result<Curve25519SeedBin, Unspecified> {
115+
fn as_be_bytes(&self) -> Result<Curve25519SeedBin<'static>, Unspecified> {
116116
let buffer = Vec::from(&self.0.private_key[..ED25519_PRIVATE_KEY_SEED_LEN]);
117117
Ok(Curve25519SeedBin::new(buffer))
118118
}

aws-lc-rs/src/encoding.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ pub trait AsBigEndian<T> {
4646
}
4747

4848
/// Elliptic curve private key data encoded as a big-endian fixed-length integer.
49-
pub type EcPrivateKeyBin = Buffer<'static, EcPrivateKeyBinType>;
49+
pub type EcPrivateKeyBin<'a> = Buffer<'a, EcPrivateKeyBinType>;
5050

5151
/// Elliptic curve private key as a DER-encoded `ECPrivateKey` (RFC 5915) structure.
52-
pub type EcPrivateKeyRfc5915Der = Buffer<'static, EcPrivateKeyRfc5915DerType>;
52+
pub type EcPrivateKeyRfc5915Der<'a> = Buffer<'a, EcPrivateKeyRfc5915DerType>;
5353

5454
/// An elliptic curve public key as a DER-encoded (X509) `SubjectPublicKeyInfo` structure
55-
pub type EcPublicKeyX509Der = Buffer<'static, EcPublicKeyX509DerType>;
55+
pub type EcPublicKeyX509Der<'a> = Buffer<'a, EcPublicKeyX509DerType>;
5656

5757
/// Elliptic curve private key data encoded as a big-endian fixed-length integer.
58-
pub type Curve25519SeedBin = Buffer<'static, Curve25519SeedBufferType>;
58+
pub type Curve25519SeedBin<'a> = Buffer<'a, Curve25519SeedBufferType>;

0 commit comments

Comments
 (0)