Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IEEE 1609.2-2022 , ETSI TS 103097 standards, InnerSubtypeConstraint #389

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ path = "benches/strings.rs"
harness = false
test = true

[[bench]]
name = "ieee1609dot2cert"
path = "benches/ieee1609dot2_bsm_cert.rs"
harness = false
test = true

[dependencies]
bitvec.workspace = true
bytes = { version = "1.7.2", default-features = false }
Expand All @@ -77,28 +83,29 @@ nom-bitvec = { package = "bitvec-nom2", version = "0.2.1" }
num-bigint = { version = "0.4.6", default-features = false }
num-traits = { version = "0.2.19", default-features = false }
num-integer = { version = "0.1.46", default-features = false, features = [
"i128",
"i128",
] }
once_cell = { version = "1.20.2", default-features = false, features = [
"race",
"alloc",
"race",
"alloc",
] }
rasn-compiler = { version = "0.5.3", optional = true }
rasn-derive = { version = "0.22", path = "macros" }
snafu = { version = "0.8.5", default-features = false, features = [
"rust_1_81",
"rust_1_81",
] }
serde_json = { version = "1", default-features = false, features = ["alloc"] }

[dev-dependencies]
criterion = { version = "0.5.1", default-features = false, features = [
"plotters",
"cargo_bench_support",
"plotters",
"cargo_bench_support",
] }
iai-callgrind = "0.14.0"
once_cell = "1.20.2"
pretty_assertions.workspace = true
rasn-pkix = { path = "standards/pkix" }
rasn-its = { path = "standards/its" }

# Assume that we need these dependencies only when benching manually on specific targets
[target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dev-dependencies]
Expand Down
165 changes: 165 additions & 0 deletions benches/ieee1609dot2_bsm_cert.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
use criterion::{criterion_group, criterion_main, Criterion};
use rasn::prelude::*;
use rasn_its::ieee1609dot2::base_types::*;
use rasn_its::ieee1609dot2::*;

pub fn build_sample() -> Ieee1609Dot2Data {
Ieee1609Dot2Data::builder()
.protocol_version(3)
.content(Ieee1609Dot2Content::SignedData(Box::new(
SignedData::builder()
.hash_id(HashAlgorithm::Sha256)
.tbs_data(
ToBeSignedData::builder()
.payload(
SignedDataPayload::builder()
.data(
Ieee1609Dot2Data::builder()
.protocol_version(3)
.content(Ieee1609Dot2Content::UnsecuredData(Opaque(
"This is a BSM\r\n".as_bytes().into(),
)))
.build(),
)
.build()
.unwrap(),
)
.header_info(
HeaderInfo::builder()
.psid(Integer::from(32).into())
.generation_time(1_230_066_625_199_609_624.into())
.build(),
)
.build(),
)
.signer(SignerIdentifier::Certificate(
vec![Certificate::from(
ImplicitCertificate::new(
CertificateBase::builder()
.version(3)
.c_type(CertificateType::Implicit)
.issuer(IssuerIdentifier::Sha256AndDigest(HashedId8(
"!\"#$%&'(".as_bytes().try_into().unwrap(),
)))
.to_be_signed(
ToBeSignedCertificate::builder()
.id(CertificateId::LinkageData(
LinkageData::builder()
.i_cert(IValue::from(100))
.linkage_value(LinkageValue(
FixedOctetString::try_from(
b"123456789".as_slice(),
)
.unwrap(),
))
.group_linkage_value(
GroupLinkageValue::builder()
.j_value(
b"ABCD".as_slice().try_into().unwrap(),
)
.value(
b"QRSTUVWXY"
.as_slice()
.try_into()
.unwrap(),
)
.build(),
)
.build(),
))
.craca_id(HashedId3(b"abc".as_slice().try_into().unwrap()))
.crl_series(CrlSeries::from(70))
.validity_period(
ValidityPeriod::builder()
.start(81_828_384.into())
.duration(Duration::Hours(169))
.build(),
)
.region(GeographicRegion::IdentifiedRegion(
vec![
IdentifiedRegion::CountryOnly(UnCountryId::from(
124,
)),
IdentifiedRegion::CountryOnly(UnCountryId::from(
484,
)),
IdentifiedRegion::CountryOnly(UnCountryId::from(
840,
)),
]
.into(),
))
.app_permissions(
vec![
PsidSsp {
psid: Integer::from(32).into(),
ssp: None,
},
PsidSsp {
psid: Integer::from(38).into(),
ssp: None,
},
]
.into(),
)
.verify_key_indicator(
VerificationKeyIndicator::ReconstructionValue(
EccP256CurvePoint::CompressedY0(
FixedOctetString::from([
0x91u8, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
0x97, 0x98, 0x91, 0x92, 0x93, 0x94, 0x95,
0x96, 0x97, 0x98, 0x91, 0x92, 0x93, 0x94,
0x95, 0x96, 0x97, 0x98,
]),
),
),
)
.build()
.unwrap(),
)
.build(),
)
.unwrap(),
)]
.into(),
))
.signature(Signature::EcdsaNistP256(
EcdsaP256Signature::builder()
.r_sig(EccP256CurvePoint::CompressedY0(
b"12345678123456781234567812345678"
.as_slice()
.try_into()
.unwrap(),
))
.s_sig(
b"ABCDEFGHABCDEFGHABCDEFGHABCDEFGH"
.as_slice()
.try_into()
.unwrap(),
)
.build(),
))
.build(),
)))
.build()
}

fn oer_enc_dec(c: &mut Criterion) {
let cert = build_sample();
let mut buffer = Vec::<u8>::with_capacity(core::mem::size_of::<Ieee1609Dot2Data>());

c.bench_function(
"RASN/ encode/decode OER ieee1609dot2 - bsm with certificate",
|b| {
b.iter(|| {
rasn::coer::encode_buf(&cert, &mut buffer).unwrap();
rasn::coer::decode::<Ieee1609Dot2Data>(&buffer).unwrap();
buffer.clear();
})
},
);
}

criterion_group!(benches, oer_enc_dec);
criterion_main!(benches);
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! Backtraces are enabled by default with `backtraces` feature.
//! See submodules for other error types.
#![allow(clippy::module_name_repetitions)]
mod components;
mod decode;
mod encode;
mod string;
Expand All @@ -25,3 +26,5 @@ pub use decode::{
pub use encode::EncodeErrorKind;
pub use encode::JerEncodeErrorKind;
pub use encode::{BerEncodeErrorKind, CodecEncodeError, CoerEncodeErrorKind, EncodeError};

pub use components::InnerSubtypeConstraintError;
Loading
Loading