Skip to content

Commit 09dfa0b

Browse files
authored
der: rename UIntRef => UintRef (#786)
From https://rust-lang.github.io/api-guidelines/naming.html > In UpperCamelCase, acronyms and contractions of compound words count > as one word: use Uuid rather than UUID, Usize rather than USize or > Stdin rather than StdIn. Based on the `Usize` example, it's pretty clear we should be using `Uint` rather than `UInt`. This is also consistent with `num-bigint` and `crypto-bigint` as of RustCrypto/crypto-bigint#143
1 parent 06ff4ec commit 09dfa0b

File tree

15 files changed

+61
-61
lines changed

15 files changed

+61
-61
lines changed

der/src/asn1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub use self::{
3232
context_specific::{ContextSpecific, ContextSpecificRef},
3333
generalized_time::GeneralizedTime,
3434
ia5_string::Ia5StringRef,
35-
integer::bigint::UIntRef,
35+
integer::bigint::UintRef,
3636
null::Null,
3737
octet_string::OctetStringRef,
3838
printable_string::PrintableStringRef,

der/src/asn1/integer/bigint.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ use crate::{
1414
/// Intended for use cases like very large integers that are used in
1515
/// cryptographic applications (e.g. keys, signatures).
1616
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
17-
pub struct UIntRef<'a> {
17+
pub struct UintRef<'a> {
1818
/// Inner value
1919
inner: ByteSlice<'a>,
2020
}
2121

22-
impl<'a> UIntRef<'a> {
23-
/// Create a new [`UIntRef`] from a byte slice.
22+
impl<'a> UintRef<'a> {
23+
/// Create a new [`UintRef`] from a byte slice.
2424
pub fn new(bytes: &'a [u8]) -> Result<Self> {
2525
let inner = ByteSlice::new(uint::strip_leading_zeroes(bytes))
2626
.map_err(|_| ErrorKind::Length { tag: Self::TAG })?;
@@ -34,7 +34,7 @@ impl<'a> UIntRef<'a> {
3434
self.inner.as_slice()
3535
}
3636

37-
/// Get the length of this [`UIntRef`] in bytes.
37+
/// Get the length of this [`UintRef`] in bytes.
3838
pub fn len(&self) -> Length {
3939
self.inner.len()
4040
}
@@ -45,7 +45,7 @@ impl<'a> UIntRef<'a> {
4545
}
4646
}
4747

48-
impl<'a> DecodeValue<'a> for UIntRef<'a> {
48+
impl<'a> DecodeValue<'a> for UintRef<'a> {
4949
fn decode_value<R: Reader<'a>>(reader: &mut R, header: Header) -> Result<Self> {
5050
let bytes = ByteSlice::decode_value(reader, header)?.as_slice();
5151
let result = Self::new(uint::decode_to_slice(bytes)?)?;
@@ -59,7 +59,7 @@ impl<'a> DecodeValue<'a> for UIntRef<'a> {
5959
}
6060
}
6161

62-
impl<'a> EncodeValue for UIntRef<'a> {
62+
impl<'a> EncodeValue for UintRef<'a> {
6363
fn value_len(&self) -> Result<Length> {
6464
uint::encoded_len(self.inner.as_slice())
6565
}
@@ -74,49 +74,49 @@ impl<'a> EncodeValue for UIntRef<'a> {
7474
}
7575
}
7676

77-
impl<'a> From<&UIntRef<'a>> for UIntRef<'a> {
78-
fn from(value: &UIntRef<'a>) -> UIntRef<'a> {
77+
impl<'a> From<&UintRef<'a>> for UintRef<'a> {
78+
fn from(value: &UintRef<'a>) -> UintRef<'a> {
7979
*value
8080
}
8181
}
8282

83-
impl<'a> TryFrom<AnyRef<'a>> for UIntRef<'a> {
83+
impl<'a> TryFrom<AnyRef<'a>> for UintRef<'a> {
8484
type Error = Error;
8585

86-
fn try_from(any: AnyRef<'a>) -> Result<UIntRef<'a>> {
86+
fn try_from(any: AnyRef<'a>) -> Result<UintRef<'a>> {
8787
any.decode_into()
8888
}
8989
}
9090

91-
impl<'a> FixedTag for UIntRef<'a> {
91+
impl<'a> FixedTag for UintRef<'a> {
9292
const TAG: Tag = Tag::Integer;
9393
}
9494

95-
impl<'a> OrdIsValueOrd for UIntRef<'a> {}
95+
impl<'a> OrdIsValueOrd for UintRef<'a> {}
9696

9797
#[cfg(test)]
9898
mod tests {
99-
use super::UIntRef;
99+
use super::UintRef;
100100
use crate::{
101101
asn1::{integer::tests::*, AnyRef},
102102
Decode, Encode, ErrorKind, SliceWriter, Tag,
103103
};
104104

105105
#[test]
106106
fn decode_uint_bytes() {
107-
assert_eq!(&[0], UIntRef::from_der(I0_BYTES).unwrap().as_bytes());
108-
assert_eq!(&[127], UIntRef::from_der(I127_BYTES).unwrap().as_bytes());
109-
assert_eq!(&[128], UIntRef::from_der(I128_BYTES).unwrap().as_bytes());
110-
assert_eq!(&[255], UIntRef::from_der(I255_BYTES).unwrap().as_bytes());
107+
assert_eq!(&[0], UintRef::from_der(I0_BYTES).unwrap().as_bytes());
108+
assert_eq!(&[127], UintRef::from_der(I127_BYTES).unwrap().as_bytes());
109+
assert_eq!(&[128], UintRef::from_der(I128_BYTES).unwrap().as_bytes());
110+
assert_eq!(&[255], UintRef::from_der(I255_BYTES).unwrap().as_bytes());
111111

112112
assert_eq!(
113113
&[0x01, 0x00],
114-
UIntRef::from_der(I256_BYTES).unwrap().as_bytes()
114+
UintRef::from_der(I256_BYTES).unwrap().as_bytes()
115115
);
116116

117117
assert_eq!(
118118
&[0x7F, 0xFF],
119-
UIntRef::from_der(I32767_BYTES).unwrap().as_bytes()
119+
UintRef::from_der(I32767_BYTES).unwrap().as_bytes()
120120
);
121121
}
122122

@@ -130,7 +130,7 @@ mod tests {
130130
I256_BYTES,
131131
I32767_BYTES,
132132
] {
133-
let uint = UIntRef::from_der(example).unwrap();
133+
let uint = UintRef::from_der(example).unwrap();
134134

135135
let mut buf = [0u8; 128];
136136
let mut encoder = SliceWriter::new(&mut buf);
@@ -143,7 +143,7 @@ mod tests {
143143

144144
#[test]
145145
fn reject_oversize_without_extra_zero() {
146-
let err = UIntRef::try_from(AnyRef::new(Tag::Integer, &[0x81]).unwrap())
146+
let err = UintRef::try_from(AnyRef::new(Tag::Integer, &[0x81]).unwrap())
147147
.err()
148148
.unwrap();
149149

der/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
//! - [`VideotexStringRef`]: ASN.1 `VideotexString`.
5757
//! - [`SequenceOf`]: ASN.1 `SEQUENCE OF`.
5858
//! - [`SetOf`], [`SetOfVec`]: ASN.1 `SET OF`.
59-
//! - [`UIntRef`]: ASN.1 unsigned `INTEGER` with raw access to encoded bytes.
59+
//! - [`UintRef`]: ASN.1 unsigned `INTEGER` with raw access to encoded bytes.
6060
//! - [`UtcTime`]: ASN.1 `UTCTime`.
6161
//! - [`Utf8StringRef`]: ASN.1 `UTF8String`.
6262
//!
@@ -328,7 +328,7 @@
328328
//! [`SequenceOf`]: asn1::SequenceOf
329329
//! [`SetOf`]: asn1::SetOf
330330
//! [`SetOfVec`]: asn1::SetOfVec
331-
//! [`UIntRef`]: asn1::UIntRef
331+
//! [`UintRef`]: asn1::UintRef
332332
//! [`UtcTime`]: asn1::UtcTime
333333
//! [`Utf8StringRef`]: asn1::Utf8StringRef
334334

pkcs1/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod version;
2222

2323
pub use der::{
2424
self,
25-
asn1::{ObjectIdentifier, UIntRef},
25+
asn1::{ObjectIdentifier, UintRef},
2626
};
2727

2828
pub use crate::{

pkcs1/src/private_key.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub(crate) mod other_prime_info;
55

66
use crate::{Error, Result, RsaPublicKey, Version};
77
use core::fmt;
8-
use der::{asn1::UIntRef, Decode, DecodeValue, Encode, Header, Reader, Sequence, Tag};
8+
use der::{asn1::UintRef, Decode, DecodeValue, Encode, Header, Reader, Sequence, Tag};
99

1010
#[cfg(feature = "alloc")]
1111
use {self::other_prime_info::OtherPrimeInfo, alloc::vec::Vec, der::SecretDocument};
@@ -39,28 +39,28 @@ use der::pem::PemLabel;
3939
#[derive(Clone)]
4040
pub struct RsaPrivateKey<'a> {
4141
/// `n`: RSA modulus.
42-
pub modulus: UIntRef<'a>,
42+
pub modulus: UintRef<'a>,
4343

4444
/// `e`: RSA public exponent.
45-
pub public_exponent: UIntRef<'a>,
45+
pub public_exponent: UintRef<'a>,
4646

4747
/// `d`: RSA private exponent.
48-
pub private_exponent: UIntRef<'a>,
48+
pub private_exponent: UintRef<'a>,
4949

5050
/// `p`: first prime factor of `n`.
51-
pub prime1: UIntRef<'a>,
51+
pub prime1: UintRef<'a>,
5252

5353
/// `q`: Second prime factor of `n`.
54-
pub prime2: UIntRef<'a>,
54+
pub prime2: UintRef<'a>,
5555

5656
/// First exponent: `d mod (p-1)`.
57-
pub exponent1: UIntRef<'a>,
57+
pub exponent1: UintRef<'a>,
5858

5959
/// Second exponent: `d mod (q-1)`.
60-
pub exponent2: UIntRef<'a>,
60+
pub exponent2: UintRef<'a>,
6161

6262
/// CRT coefficient: `(inverse of q) mod p`.
63-
pub coefficient: UIntRef<'a>,
63+
pub coefficient: UintRef<'a>,
6464

6565
/// Additional primes `r_3`, ..., `r_u`, in order, if this is a multi-prime
6666
/// RSA key (i.e. `version` is `multi`).

pkcs1/src/private_key/other_prime_info.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! PKCS#1 OtherPrimeInfo support.
22
3-
use der::{asn1::UIntRef, DecodeValue, Encode, Header, Reader, Sequence};
3+
use der::{asn1::UintRef, DecodeValue, Encode, Header, Reader, Sequence};
44

55
/// PKCS#1 OtherPrimeInfo as defined in [RFC 8017 Appendix 1.2].
66
///
@@ -19,13 +19,13 @@ use der::{asn1::UIntRef, DecodeValue, Encode, Header, Reader, Sequence};
1919
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
2020
pub struct OtherPrimeInfo<'a> {
2121
/// Prime factor `r_i` of `n`, where `i` >= 3.
22-
pub prime: UIntRef<'a>,
22+
pub prime: UintRef<'a>,
2323

2424
/// Exponent: `d_i = d mod (r_i - 1)`.
25-
pub exponent: UIntRef<'a>,
25+
pub exponent: UintRef<'a>,
2626

2727
/// CRT coefficient: `t_i = (r_1 * r_2 * ... * r_(i-1))^(-1) mod r_i`.
28-
pub coefficient: UIntRef<'a>,
28+
pub coefficient: UintRef<'a>,
2929
}
3030

3131
impl<'a> DecodeValue<'a> for OtherPrimeInfo<'a> {

pkcs1/src/public_key.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! PKCS#1 RSA Public Keys.
22
33
use crate::{Error, Result};
4-
use der::{asn1::UIntRef, Decode, DecodeValue, Encode, Header, Reader, Sequence};
4+
use der::{asn1::UintRef, Decode, DecodeValue, Encode, Header, Reader, Sequence};
55

66
#[cfg(feature = "alloc")]
77
use der::Document;
@@ -24,10 +24,10 @@ use der::pem::PemLabel;
2424
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
2525
pub struct RsaPublicKey<'a> {
2626
/// `n`: RSA modulus
27-
pub modulus: UIntRef<'a>,
27+
pub modulus: UintRef<'a>,
2828

2929
/// `e`: RSA public exponent
30-
pub public_exponent: UIntRef<'a>,
30+
pub public_exponent: UintRef<'a>,
3131
}
3232

3333
impl<'a> DecodeValue<'a> for RsaPublicKey<'a> {

x509-cert/src/certificate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use alloc::vec::Vec;
66
use core::cmp::Ordering;
77

88
use const_oid::AssociatedOid;
9-
use der::asn1::{BitStringRef, UIntRef};
9+
use der::asn1::{BitStringRef, UintRef};
1010
use der::{Decode, Enumerated, Error, ErrorKind, Sequence, ValueOrd};
1111
use spki::{AlgorithmIdentifier, SubjectPublicKeyInfo};
1212

@@ -83,7 +83,7 @@ pub struct TbsCertificate<'a> {
8383
#[asn1(context_specific = "0", default = "Default::default")]
8484
pub version: Version,
8585

86-
pub serial_number: UIntRef<'a>,
86+
pub serial_number: UintRef<'a>,
8787
pub signature: AlgorithmIdentifier<'a>,
8888
pub issuer: Name<'a>,
8989
pub validity: Validity,

x509-cert/src/crl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::Version;
77

88
use alloc::vec::Vec;
99

10-
use der::asn1::{BitStringRef, UIntRef};
10+
use der::asn1::{BitStringRef, UintRef};
1111
use der::{Sequence, ValueOrd};
1212
use spki::AlgorithmIdentifier;
1313

@@ -47,7 +47,7 @@ pub struct CertificateList<'a> {
4747
#[derive(Clone, Debug, Eq, PartialEq, Sequence, ValueOrd)]
4848
#[allow(missing_docs)]
4949
pub struct RevokedCert<'a> {
50-
pub serial_number: UIntRef<'a>,
50+
pub serial_number: UintRef<'a>,
5151
pub revocation_date: Time,
5252
pub crl_entry_extensions: Option<Extensions<'a>>,
5353
}

x509-cert/src/ext/pkix/authkeyid.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::name::GeneralNames;
22

33
use const_oid::db::rfc5280::ID_CE_AUTHORITY_KEY_IDENTIFIER;
44
use const_oid::{AssociatedOid, ObjectIdentifier};
5-
use der::asn1::{OctetStringRef, UIntRef};
5+
use der::asn1::{OctetStringRef, UintRef};
66
use der::Sequence;
77

88
/// AuthorityKeyIdentifier as defined in [RFC 5280 Section 4.2.1.1].
@@ -28,7 +28,7 @@ pub struct AuthorityKeyIdentifier<'a> {
2828
pub authority_cert_issuer: Option<GeneralNames<'a>>,
2929

3030
#[asn1(context_specific = "2", tag_mode = "IMPLICIT", optional = "true")]
31-
pub authority_cert_serial_number: Option<UIntRef<'a>>,
31+
pub authority_cert_serial_number: Option<UintRef<'a>>,
3232
}
3333

3434
impl<'a> AssociatedOid for AuthorityKeyIdentifier<'a> {

x509-cert/src/ext/pkix/certpolicy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use alloc::vec::Vec;
44

55
use const_oid::db::rfc5912::ID_CE_CERTIFICATE_POLICIES;
66
use const_oid::AssociatedOid;
7-
use der::asn1::{GeneralizedTime, Ia5StringRef, ObjectIdentifier, UIntRef, Utf8StringRef};
7+
use der::asn1::{GeneralizedTime, Ia5StringRef, ObjectIdentifier, UintRef, Utf8StringRef};
88
use der::{AnyRef, Choice, Sequence, ValueOrd};
99

1010
/// CertificatePolicies as defined in [RFC 5280 Section 4.2.1.4].
@@ -98,7 +98,7 @@ pub struct UserNotice<'a> {
9898
#[allow(missing_docs)]
9999
pub struct NoticeReference<'a> {
100100
pub organization: DisplayText<'a>,
101-
pub notice_numbers: Option<Vec<UIntRef<'a>>>,
101+
pub notice_numbers: Option<Vec<UintRef<'a>>>,
102102
}
103103

104104
/// DisplayText as defined in [RFC 5280 Section 4.2.1.4].

x509-cert/src/ext/pkix/crl.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub use dp::IssuingDistributionPoint;
1111

1212
use alloc::vec::Vec;
1313

14-
use der::{asn1::UIntRef, Enumerated};
14+
use der::{asn1::UintRef, Enumerated};
1515

1616
/// CrlNumber as defined in [RFC 5280 Section 5.2.3].
1717
///
@@ -21,13 +21,13 @@ use der::{asn1::UIntRef, Enumerated};
2121
///
2222
/// [RFC 5280 Section 5.2.3]: https://datatracker.ietf.org/doc/html/rfc5280#section-5.2.3
2323
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
24-
pub struct CrlNumber<'a>(pub UIntRef<'a>);
24+
pub struct CrlNumber<'a>(pub UintRef<'a>);
2525

2626
impl<'a> AssociatedOid for CrlNumber<'a> {
2727
const OID: ObjectIdentifier = ID_CE_CRL_NUMBER;
2828
}
2929

30-
impl_newtype!(CrlNumber<'a>, UIntRef<'a>);
30+
impl_newtype!(CrlNumber<'a>, UintRef<'a>);
3131

3232
/// BaseCRLNumber as defined in [RFC 5280 Section 5.2.4].
3333
///
@@ -37,13 +37,13 @@ impl_newtype!(CrlNumber<'a>, UIntRef<'a>);
3737
///
3838
/// [RFC 5280 Section 5.2.4]: https://datatracker.ietf.org/doc/html/rfc5280#section-5.2.4
3939
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
40-
pub struct BaseCrlNumber<'a>(pub UIntRef<'a>);
40+
pub struct BaseCrlNumber<'a>(pub UintRef<'a>);
4141

4242
impl<'a> AssociatedOid for BaseCrlNumber<'a> {
4343
const OID: ObjectIdentifier = ID_CE_DELTA_CRL_INDICATOR;
4444
}
4545

46-
impl_newtype!(BaseCrlNumber<'a>, UIntRef<'a>);
46+
impl_newtype!(BaseCrlNumber<'a>, UintRef<'a>);
4747

4848
/// CrlDistributionPoints as defined in [RFC 5280 Section 4.2.1.13].
4949
///

x509-cert/tests/certificate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Certificate tests
22
33
use der::{
4-
asn1::{BitStringRef, ContextSpecific, ObjectIdentifier, UIntRef},
4+
asn1::{BitStringRef, ContextSpecific, ObjectIdentifier, UintRef},
55
Decode, DecodeValue, Encode, FixedTag, Header, Reader, Tag, Tagged,
66
};
77
use hex_literal::hex;
@@ -207,7 +207,7 @@ fn decode_cert() {
207207
];
208208
assert_eq!(
209209
cert.tbs_certificate.serial_number,
210-
UIntRef::new(&target_serial).unwrap()
210+
UintRef::new(&target_serial).unwrap()
211211
);
212212
assert_eq!(
213213
cert.tbs_certificate.signature.oid.to_string(),

0 commit comments

Comments
 (0)