qnighy / yasna.rs

ASN.1 library for Rust
Apache License 2.0
42 stars 31 forks source link

no method named `read_biguint` #37

Closed Taoja closed 5 years ago

Taoja commented 5 years ago

abort by error

error[E0599]: no method named `read_biguint` found for type `yasna::reader::BERReader<'_, '_>` in the current scope
  --> src/sm2/signature.rs:44:39
   |
44 |                 let r = reader.next().read_biguint()?;
   |                                       ^^^^^^^^^^^^

error[E0599]: no method named `read_biguint` found for type `yasna::reader::BERReader<'_, '_>` in the current scope
  --> src/sm2/signature.rs:45:39
   |
45 |                 let s = reader.next().read_biguint()?;
   |                                       ^^^^^^^^^^^^

error[E0599]: no method named `write_biguint` found for type `yasna::writer::DERWriter<'_>` in the current scope
  --> src/sm2/signature.rs:78:31
   |
78 |                 writer.next().write_biguint(&self.r);
   |                               ^^^^^^^^^^^^^

error[E0599]: no method named `write_biguint` found for type `yasna::writer::DERWriter<'_>` in the current scope
  --> src/sm2/signature.rs:79:31
   |
79 |                 writer.next().write_biguint(&self.s);
   |                               ^^^^^^^^^^^^^

error: aborting due to 4 previous errors

my code

use yasna;

pub fn der_decode(buf: &[u8]) -> Result<Signature, yasna::ASN1Error> {
        let (r, s) = yasna::parse_der(buf, |reader| {
            reader.read_sequence(|reader| {
                let r = reader.next().read_biguint()?;
                let s = reader.next().read_biguint()?;
                Ok((r, s))
            })
        })?;
        Ok(Signature { r, s })
    }
pub fn der_encode(&self) -> Vec<u8> {
        yasna::construct_der(|writer| {
            writer.write_sequence(|writer| {
                writer.next().write_biguint(&self.r);
                writer.next().write_biguint(&self.s);
            })
        })
    }
qnighy commented 5 years ago

You're likely missing num-bigint feature in your [dependencies] section. See https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#choosing-features

Taoja commented 5 years ago

ok,thx