Skip to content

Commit

Permalink
fix: Enable non-canister code on aarch64 as well
Browse files Browse the repository at this point in the history
  • Loading branch information
yanliu38 committed Jan 25, 2025
1 parent 0b57684 commit f60a29e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ tempfile.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
ic-cdk.workspace = true

[target.'cfg(target_arch = "x86_64")'.dependencies]
[target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dependencies]
fs-err.workspace = true
20 changes: 10 additions & 10 deletions common/src/dcc_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use hmac::{Hmac, Mac};
use ic_cdk::println;
use pkcs8::der::zeroize::Zeroizing;
use std::error::Error;
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use std::io::Read;
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use std::io::Write;
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use std::path::PathBuf;

use crate::ED25519_SIGN_CONTEXT;
Expand Down Expand Up @@ -218,7 +218,7 @@ impl DccIdentity {
.replace('\n', "")
}

#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
pub fn write_verifying_key_to_pem_file(&self, file_path: &PathBuf) -> Result<(), CryptoError> {
let pem_string = self.verifying_key_as_pem();

Expand Down Expand Up @@ -246,7 +246,7 @@ impl DccIdentity {
Ok(pem::encode(&pem_obj))
}

#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
pub fn write_signing_key_to_pem_file(&self, file_path: &PathBuf) -> Result<(), CryptoError> {
let pem_string = self.signing_key_as_pem_string()?;

Expand All @@ -257,15 +257,15 @@ impl DccIdentity {
Ok(())
}

#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
pub fn identities_dir() -> PathBuf {
dirs::home_dir()
.expect("Failed to find home directory")
.join(".dcc")
.join("identity")
}

#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
pub fn save_to_dir(&self, identity: &str) -> Result<(), CryptoError> {
let identity_dir = Self::identities_dir().join(identity);

Expand All @@ -290,7 +290,7 @@ impl DccIdentity {
Ok(())
}

#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
fn read_signing_key_from_pem_file(file_path: &PathBuf) -> Result<SigningKey, CryptoError> {
let mut file = fs_err::File::open(file_path)?;
let mut pem_string = String::new();
Expand All @@ -305,7 +305,7 @@ impl DccIdentity {
Ok(key)
}

#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
fn read_verifying_key_from_pem_file(file_path: &PathBuf) -> Result<VerifyingKey, CryptoError> {
let mut file = fs_err::File::open(file_path)?;
let mut pem_string = String::new();
Expand All @@ -327,7 +327,7 @@ impl DccIdentity {
Ok(key)
}

#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
pub fn load_from_dir(identity_dir: &PathBuf) -> Result<Self, CryptoError> {
let identity_dir = if identity_dir.is_absolute() {
identity_dir.to_path_buf()
Expand Down

0 comments on commit f60a29e

Please sign in to comment.