Closed Ravindra1618 closed 1 year ago
Hey,
I think the reason you're getting the error is because your digest does not have the right size. You selected SHA256, but only provided 8 bytes as a digest - you need to use 32 bytes. So if you replace val
with vec![0xff;32]
or something like that, it should work.
Thank You @ionut-arm
Any suggestions for this error should be helpful
use std::fs; use tss_esapi::Context; use tss_esapi::abstraction::transient::KeyMaterial; use tss_esapi::abstraction::transient::TransientKeyContextBuilder; use tss_esapi::constants::SessionType; use tss_esapi::interface_types::algorithm::HashingAlgorithm; use tss_esapi::interface_types::algorithm::RsaSchemeAlgorithm; use tss_esapi::interface_types::key_bits::RsaKeyBits; use tss_esapi::interface_types::resource_handles::Hierarchy; use tss_esapi::structures::Digest; use tss_esapi::structures::RsaExponent; use tss_esapi::structures::RsaScheme; use tss_esapi::structures::SymmetricDefinition; use tss_esapi::tcti_ldr::TctiNameConf; use tss_esapi::tcti_ldr::DeviceConfig;
fn main() { let device_conf: DeviceConfig = DeviceConfig::default(); let create_ctx = TransientKeyContextBuilder::new() .with_tcti(TctiNameConf::Device(device_conf)) .build() .unwrap();
let mut ctx = create_ctx; let key_params = tss_esapi::abstraction::transient::KeyParams::Rsa { size: RsaKeyBits::Rsa3072, scheme: RsaScheme::create(RsaSchemeAlgorithm::RsaSsa, Some(HashingAlgorithm::Sha256)) .expect("Failed to create RSA scheme"), pub_exponent: RsaExponent::default(), }; let (key, auth) = ctx.create_key(key_params,32).unwrap(); let val = vec![2,3,4,56,7,77,8,8]; let digest : Digest = Digest::try_from(val).unwrap(); let digest1 = ctx.sign(key,key_params,auth,digest);
}
The error is ERROR:esys:src/tss2-esys/api/Esys_Sign.c:105:Esys_Sign() Esys Finish ErrorCode (0x000001d5)
Originally posted by @Ravindra1618 in https://github.com/parallaxsecond/rust-tss-esapi/issues/399#issuecomment-1538088287