Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
feat/validate-attestation-with-pubkey (#142)
Browse files Browse the repository at this point in the history
* feat: now using just the pub key to validate the attestation root cert

* chore: cargo fmt

* chore: fixed test
  • Loading branch information
godenzim committed Dec 15, 2023
1 parent 5de70c7 commit 742f1ec
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 50 deletions.
1 change: 1 addition & 0 deletions pallets/acurast/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ std = [
"sp-std/std",
"codec/std",
"scale-info/std",
"asn1?/std",
"serde",
]
attestation = [
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed pallets/acurast/common/src/__root_certs__/root_4.cer
Binary file not shown.
Binary file added pallets/acurast/common/src/__root_key__/public.key
Binary file not shown.
53 changes: 13 additions & 40 deletions pallets/acurast/common/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ const ECDSA_WITH_SHA384_ALGORITHM: ObjectIdentifier = oid!(1, 2, 840, 10045, 4,
const RSA_PBK: ObjectIdentifier = oid!(1, 2, 840, 113549, 1, 1, 1);
const ECDSA_PBK: ObjectIdentifier = oid!(1, 2, 840, 10045, 2, 1);

#[derive(Clone)]
#[derive(Clone, Eq, PartialEq)]
pub enum PublicKey {
RSA(RSAPbk),
ECDSA(ECDSACurve),
}

#[derive(Clone)]
#[derive(Clone, Eq, PartialEq)]
pub struct RSAPbk {
exponent: BigUint,
modulus: BigUint,
}

#[derive(Clone)]
#[derive(Clone, Eq, PartialEq)]
pub enum ECDSACurve {
CurveP256(VerifyingKey),
CurveP384(p384::AffinePoint),
Expand Down Expand Up @@ -279,16 +279,6 @@ pub fn peek_attestation_version(data: &[u8]) -> Result<i64, ParseError> {
result
}

pub fn validate_certificate_chain_root(
chain: &CertificateChainInput,
) -> Result<(), ValidationError> {
let first = chain.first().ok_or(ValidationError::ChainTooShort)?;
if !TRUSTED_ROOT_CERTS.contains(&first.as_slice()) {
return Err(ValidationError::UntrustedRoot);
}
Ok(())
}

/// Validates the chain by ensuring that
///
/// - the chain starts with a self-signed certificate at index 0 that matches one of the known [TRUSTED_ROOT_CERTS]
Expand All @@ -297,13 +287,19 @@ pub fn validate_certificate_chain_root(
pub fn validate_certificate_chain<'a>(
chain: &'a CertificateChainInput,
) -> Result<(Vec<CertificateId>, TBSCertificate<'a>, PublicKey), ValidationError> {
let root_pub_key = PublicKey::parse(&asn1::parse_single::<SubjectPublicKeyInfo>(
TRUSTED_ROOT_PUB_KEY,
)?)?;
let mut cert_ids = Vec::<CertificateId>::new();
let fold_result = chain.iter().try_fold::<_, _, Result<_, ValidationError>>(
(Option::<PublicKey>::None, Option::<Certificate>::None),
|(prev_pbk, _), cert_data| {
let cert = parse_cert(&cert_data)?;
let payload = parse_cert_payload(&cert_data)?;
let current_pbk = PublicKey::parse(&cert.tbs_certificate.subject_public_key_info)?;
if prev_pbk.is_none() && current_pbk != root_pub_key {
return Err(ValidationError::UntrustedRoot);
}

validate(&cert, payload, prev_pbk.as_ref().unwrap_or(&current_pbk))?;

Expand All @@ -326,25 +322,7 @@ pub fn validate_certificate_chain<'a>(
Ok((cert_ids, last_cert.tbs_certificate, last_cert_pbk))
}

/// The list of trusted root certificates, as decoded bytes arrays. [Source](https://developer.android.com/training/articles/security-key-attestation#root_certificate)
///
// Adding new root certificate:
//
// use std::io::Write;
// let mut output = File::create("./__root_certs__/root_x.cer").unwrap();
// let line = base64::decode(r"<base64>").unwrap();
// output.write_all(&line);
//
const TRUSTED_ROOT_CERTS: &[&[u8]] = &[
// base64 equivalent: r"MIIFYDCCA0igAwIBAgIJAOj6GWMU0voYMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNVBAUTEGY5MjAwOWU4NTNiNmIwNDUwHhcNMTYwNTI2MTYyODUyWhcNMjYwNTI0MTYyODUyWjAbMRkwFwYDVQQFExBmOTIwMDllODUzYjZiMDQ1MIICIjANBgkqhkiG9w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0C17JEgMLb4kvrqsXZs01U3mB/qABg/1t5Pd5AORHARs1hhqGICW/nKMav574f9rZN4PC2ZlufGXb7sIdJpGiO9ctRhiLuYuly10JccUZGEHpHSYM2GtkgYbZba6lsCPYAAP83cyDV+1aOkTf1RCp/lM0PKvmxYN10RYsK631jrleGdcdkxoSK//mSQbgcWnmAEZrzHoF1/0gso1HZgIn0YLzVhLSA/iXCX4QT2h3J5z3znluKG1nv8NQdxei2DIIhASWfu804CA96cQKTTlaae2fweqXjdN1/v2nqOhngNyz1361mFmr4XmaKH/ItTwOe72NI9ZcwS1lVaCvsIkTDCEXdm9rCNPAY10iTunIHFXRh+7KPzlHGewCq/8TOohBRn0/NNfh7uRslOSZ/xKbN9tMBtw37Z8d2vvnXq/YWdsm1+JLVwn6yYD/yacNJBlwpddla8eaVMjsF6nBnIgQOf9zKSe06nSTqvgwUHosgOECZJZ1EuzbH4yswbt02tKtKEFhx+v+OTge/06V+jGsqTWLsfrOCNLuA8H++z+pUENmpqnnHovaI47gC+TNpkgYGkkBT6B/m/U01BuOBBTzhIlMEZq9qkDWuM2cA5kW5V3FJUcfHnw1IdYIg2Wxg7yHcQZemFQg=="
include_bytes!("./__root_certs__/root_4.cer"),
];
const TRUSTED_ROOT_PUB_KEY: &'static [u8] = include_bytes!("./__root_key__/public.key");

#[cfg(test)]
mod tests {
Expand All @@ -356,8 +334,7 @@ mod tests {
};

use super::{
asn::KeyDescription, validate_certificate_chain, validate_certificate_chain_root,
CertificateChainInput, CertificateInput,
asn::KeyDescription, validate_certificate_chain, CertificateChainInput, CertificateInput,
};

pub fn decode_certificate_chain(chain: &Vec<&str>) -> CertificateChainInput {
Expand Down Expand Up @@ -402,7 +379,6 @@ mod tests {
SAMSUNG_KEY_CERT,
];
let decoded_chain = decode_certificate_chain(&chain);
validate_certificate_chain_root(&decoded_chain)?;
let (_, cert, _) = validate_certificate_chain(&decoded_chain)?;
let key_description = extract_attestation(cert.extensions)?;
match &key_description {
Expand All @@ -423,7 +399,6 @@ mod tests {
hex_literal::hex!("308201fe30820185a00302010202106fd912a55cb7563380ddfa2ac2d1eb8c300a06082a8648ce3d040302303f31123010060355040c0c095374726f6e67426f7831293027060355040513203138346464346137643861373133316539386161653465613761663531306461301e170d3231303931353232353831375a170d3331303931333232353831375a303f31123010060355040c0c095374726f6e67426f78312930270603550405132037386235656561343461313465353437373261363862653665623738313462343059301306072a8648ce3d020106082a8648ce3d03010703420004df1afbe9c0d1fb4d291a6573de2cdf95ca9f43e4bd2f33ded358ca8118dd42ea619a9cdbccd4cc32335f5db51774bb5e9ccf08a2d6d3259572a27fe064fd451da3633061301d0603551d0e04160414f40c71002bcb6425158db7b4b552d09820d9e4c9301f0603551d2304183016801448e9cf69260a89c4c584499c6dbad846e5a266b3300f0603551d130101ff040530030101ff300e0603551d0f0101ff040403020204300a06082a8648ce3d0403020367003064023044f91fe977e5ddba9c69a4f0b0d9b7c550e8e117216d6768b3477e4277fb88e9ed1dcae08c538b5452f30f4aabd473c10230312efaac05f998263283e0b718025eaa224ee8e386b6f143b9781c789f3a38abc8480731325893d6efc25b67c473ecf8").to_vec().try_into().unwrap(),
hex_literal::hex!("308202ba30820260a003020102020101300a06082a8648ce3d040302303f31123010060355040c0c095374726f6e67426f7831293027060355040513203738623565656134346131346535343737326136386265366562373831346234301e170d3730303130313030303030305a170d3439313233313233353935395a301f311d301b06035504031314416e64726f6964204b657973746f7265204b65793059301306072a8648ce3d020106082a8648ce3d03010703420004e203b4ed148733aca6322978ffb9d72dc940919d489d87ae5242cf6eb39b6ae8ab9edf67310b5b88e8ab5e82f7ec6cb7778ad00c480e4846aa6dbbde55303b43a382016b30820167300c0603551d0f0405030307880030820155060a2b06010401d67902011104820145308201410201640a01020201640a0102042052331675bfbad8106ff561287fcb0397307dc4ed8cccc3f7e2ace4a7fe82f19c04003065bf853d080206018c1a85f13ebf85455504533051312b30290424636f6d2e616375726173742e61747465737465642e6578656375746f722e63616e61727902011031220420ec70c2a4e072a0f586552a68357b23697c9d45f1e1257a8c4d29a25ac49824333081a7a10b3109020106020103020102a203020103a30402020100a5053103020100aa03020101bf8377020500bf853e03020100bf85404c304a0420c276f9fcf895a8838c8d6e6ec441494822e69acfca3bb27715790b2951da33980101ff0a010004209b51df228d989cd600b59e307b0bbc1d92013f969d4cebcc0ca3e1556bff6e7bbf854105020301fbd0bf854205020303163fbf854e0602040134b09dbf854f0602040134b09d300a06082a8648ce3d040302034800304502200229006e3a528c45224739b7773731c99ca811fa3ee57121626bbc9279fad3af022100bf47d355feae07bb6a4528e8872a8775248d4960477ce807cf4ee7ce902d42b9").to_vec().try_into().unwrap(),
].to_vec().try_into().unwrap();
validate_certificate_chain_root(&decoded_chain)?;
let (_, cert, _) = validate_certificate_chain(&decoded_chain)?;
let key_description = extract_attestation(cert.extensions)?;
match &key_description {
Expand Down Expand Up @@ -469,7 +444,6 @@ mod tests {

for chain in chains {
let decoded_chain = decode_certificate_chain(&chain);
validate_certificate_chain_root(&decoded_chain).expect("validating root failed");
let (_, cert, _) =
validate_certificate_chain(&decoded_chain).expect("validating chain failed");
let key_description = extract_attestation(cert.extensions).map_err(|err| {
Expand Down Expand Up @@ -507,7 +481,6 @@ mod tests {
PIXEL_KEY_CERT_INVALID,
];
let decoded_chain = decode_certificate_chain(&chain);
validate_certificate_chain_root(&decoded_chain).expect("validating root failed");
let res = validate_certificate_chain(&decoded_chain);
match res {
Err(e) => assert_eq!(e, ValidationError::InvalidSignature),
Expand All @@ -525,9 +498,9 @@ mod tests {
PIXEL_KEY_CERT_INVALID,
];
let decoded_chain = decode_certificate_chain(&chain);
let res = validate_certificate_chain_root(&decoded_chain);
let res = validate_certificate_chain(&decoded_chain);
match res {
Err(e) => assert_eq!(e, ValidationError::UntrustedRoot),
Err(e) => assert_eq!(e, ValidationError::InvalidSignature),
_ => return Err(()),
};
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion pallets/acurast/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ fn test_submit_attestation_failure_1() {
RuntimeOrigin::signed(processor_account_id()).into(),
chain.clone()
),
Error::<Test>::RootCertificateValidationFailed
Error::<Test>::CertificateChainValidationFailed
);

assert_eq!(None, Acurast::stored_attestation(processor_account_id()));
Expand Down
8 changes: 1 addition & 7 deletions pallets/acurast/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use acurast_common::{
extract_attestation, validate_certificate_chain, validate_certificate_chain_root, ECDSACurve,
PublicKey,
};
use acurast_common::{extract_attestation, validate_certificate_chain, ECDSACurve, PublicKey};
use codec::Encode;
use frame_support::{ensure, traits::UnixTime};
use sp_std::prelude::*;
Expand All @@ -16,9 +13,6 @@ pub fn validate_and_extract_attestation<T: Config>(
source: &T::AccountId,
attestation_chain: &AttestationChain,
) -> Result<Attestation, Error<T>> {
validate_certificate_chain_root(&attestation_chain.certificate_chain)
.map_err(|_| Error::<T>::RootCertificateValidationFailed)?;

let (cert_ids, cert, public_key) =
validate_certificate_chain(&attestation_chain.certificate_chain)
.map_err(|_| Error::<T>::CertificateChainValidationFailed)?;
Expand Down
3 changes: 1 addition & 2 deletions pallets/vesting/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::marker::PhantomData;

use frame_support::pallet_prelude::*;
use frame_support::{
parameter_types,
sp_runtime::{
Expand Down Expand Up @@ -137,7 +136,7 @@ impl<T: Config + mock_pallet::Config> VestingBalance<T::AccountId, T::Balance>
Ok(())
}

fn adjust_lock(acc: &T::AccountId, stake: T::Balance) {}
fn adjust_lock(_acc: &T::AccountId, _stake: T::Balance) {}

fn pay_accrued(
target: &T::AccountId,
Expand Down

0 comments on commit 742f1ec

Please sign in to comment.