From 360c3949c8abd3b1d1eff3cfca6ab6c034b343fd Mon Sep 17 00:00:00 2001 From: 0x676e67 Date: Fri, 21 Mar 2025 17:56:57 +0800 Subject: [PATCH] build: fix doc test --- boring/src/aes.rs | 2 +- boring/src/asn1.rs | 2 +- boring/src/bn.rs | 28 ++++++++++++++-------------- boring/src/dsa.rs | 6 +++--- boring/src/ec.rs | 8 ++++---- boring/src/error.rs | 4 ++-- boring/src/hash.rs | 4 ++-- boring/src/memcmp.rs | 4 ++-- boring/src/nid.rs | 2 +- boring/src/pkey.rs | 4 ++-- boring/src/rand.rs | 4 ++-- boring/src/rsa.rs | 2 +- boring/src/sha.rs | 4 ++-- boring/src/sign.rs | 8 ++++---- boring/src/ssl/mod.rs | 4 ++-- boring/src/symm.rs | 12 ++++++------ boring/src/x509/extension.rs | 4 ++-- boring/src/x509/mod.rs | 6 +++--- boring/src/x509/store.rs | 14 +++++++------- tokio-boring/README.md | 2 +- 20 files changed, 62 insertions(+), 62 deletions(-) diff --git a/boring/src/aes.rs b/boring/src/aes.rs index 8a47cbaf..56853cf2 100644 --- a/boring/src/aes.rs +++ b/boring/src/aes.rs @@ -22,7 +22,7 @@ //! //! ## Key wrapping //! ```rust -//! use boring::aes::{AesKey, unwrap_key, wrap_key}; +//! use boring2::aes::{AesKey, unwrap_key, wrap_key}; //! //! let kek = b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; //! let key_to_wrap = b"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF"; diff --git a/boring/src/asn1.rs b/boring/src/asn1.rs index 9fb3fcaf..616ce54a 100644 --- a/boring/src/asn1.rs +++ b/boring/src/asn1.rs @@ -21,7 +21,7 @@ //! ## Examples //! //! ``` -//! use boring::asn1::Asn1Time; +//! use boring2::asn1::Asn1Time; //! let tomorrow = Asn1Time::days_from_now(1); //! ``` use crate::ffi; diff --git a/boring/src/bn.rs b/boring/src/bn.rs index 58edbabb..37fa1707 100644 --- a/boring/src/bn.rs +++ b/boring/src/bn.rs @@ -9,8 +9,8 @@ //! # Examples //! //! ``` -//! use boring::bn::BigNum; -//! use boring::error::ErrorStack; +//! use boring2::bn::BigNum; +//! use boring2::error::ErrorStack; //! //! fn main() -> Result<(), ErrorStack> { //! let a = BigNum::new()?; // a = 0 @@ -97,8 +97,8 @@ foreign_type_and_impl_send_sync! { /// /// # Examples /// ``` - /// use boring::bn::BigNum; - /// # use boring::error::ErrorStack; + /// use boring2::bn::BigNum; + /// # use boring2::error::ErrorStack; /// # fn bignums() -> Result< (), ErrorStack > { /// let little_big = BigNum::from_u32(std::u32::MAX)?; /// assert_eq!(*&little_big.num_bytes(), 4); @@ -271,7 +271,7 @@ impl BigNumRef { /// # Examples /// /// ``` - /// # use boring::bn::BigNum; + /// # use boring2::bn::BigNum; /// # use std::cmp::Ordering; /// let s = -BigNum::from_u32(8).unwrap(); /// let o = BigNum::from_u32(8).unwrap(); @@ -311,8 +311,8 @@ impl BigNumRef { /// # Examples /// /// ``` - /// use boring::bn::{BigNum, MsbOption}; - /// use boring::error::ErrorStack; + /// use boring2::bn::{BigNum, MsbOption}; + /// use boring2::error::ErrorStack; /// /// fn generate_random() -> Result< BigNum, ErrorStack > { /// let mut big = BigNum::new()?; @@ -365,8 +365,8 @@ impl BigNumRef { /// # Examples /// /// ``` - /// use boring::bn::BigNum; - /// use boring::error::ErrorStack; + /// use boring2::bn::BigNum; + /// use boring2::error::ErrorStack; /// /// fn generate_weak_prime() -> Result< BigNum, ErrorStack > { /// let mut big = BigNum::new()?; @@ -724,7 +724,7 @@ impl BigNumRef { /// `self` can be recreated by using `from_slice`. /// /// ``` - /// # use boring::bn::BigNum; + /// # use boring2::bn::BigNum; /// let s = -BigNum::from_u32(4543).unwrap(); /// let r = BigNum::from_u32(4543).unwrap(); /// @@ -750,7 +750,7 @@ impl BigNumRef { /// `self` can be recreated by using `from_slice`. /// /// ``` - /// # use boring::bn::BigNum; + /// # use boring2::bn::BigNum; /// let bn = BigNum::from_u32(0x4543).unwrap(); /// /// let bn_vec = bn.to_vec_padded(4).unwrap(); @@ -775,7 +775,7 @@ impl BigNumRef { /// Returns a decimal string representation of `self`. /// /// ``` - /// # use boring::bn::BigNum; + /// # use boring2::bn::BigNum; /// let s = -BigNum::from_u32(12345).unwrap(); /// /// assert_eq!(&**s.to_dec_str().unwrap(), "-12345"); @@ -791,7 +791,7 @@ impl BigNumRef { /// Returns a hexadecimal string representation of `self`. /// /// ``` - /// # use boring::bn::BigNum; + /// # use boring2::bn::BigNum; /// let s = -BigNum::from_u32(0x99ff).unwrap(); /// /// assert_eq!(&**s.to_hex_str().unwrap(), "-99ff"); @@ -864,7 +864,7 @@ impl BigNum { /// [`BN_bin2bn`]: https://www.openssl.org/docs/man1.1.0/crypto/BN_bin2bn.html /// /// ``` - /// # use boring::bn::BigNum; + /// # use boring2::bn::BigNum; /// let bignum = BigNum::from_slice(&[0x12, 0x00, 0x34]).unwrap(); /// /// assert_eq!(bignum, BigNum::from_u32(0x120034).unwrap()); diff --git a/boring/src/dsa.rs b/boring/src/dsa.rs index 72d6947e..b0f3d4a2 100644 --- a/boring/src/dsa.rs +++ b/boring/src/dsa.rs @@ -41,9 +41,9 @@ generic_foreign_type_and_impl_send_sync! { /// # Examples /// /// ``` - /// use boring::dsa::Dsa; - /// use boring::error::ErrorStack; - /// use boring::pkey::Private; + /// use boring2::dsa::Dsa; + /// use boring2::error::ErrorStack; + /// use boring2::pkey::Private; /// /// fn create_dsa() -> Result, ErrorStack> { /// let sign = Dsa::generate(2048)?; diff --git a/boring/src/ec.rs b/boring/src/ec.rs index 8008927a..696399bd 100644 --- a/boring/src/ec.rs +++ b/boring/src/ec.rs @@ -602,10 +602,10 @@ impl EcKey { /// # Example /// /// ```no_run - /// use boring::bn::BigNumContext; - /// use boring::ec::*; - /// use boring::nid::Nid; - /// use boring::pkey::PKey; + /// use boring2::bn::BigNumContext; + /// use boring2::ec::*; + /// use boring2::nid::Nid; + /// use boring2::pkey::PKey; /// /// // get bytes from somewhere, i.e. this will not produce a valid key /// let public_key: Vec = vec![]; diff --git a/boring/src/error.rs b/boring/src/error.rs index 9cdc878b..32d6304a 100644 --- a/boring/src/error.rs +++ b/boring/src/error.rs @@ -6,8 +6,8 @@ //! # Examples //! //! ``` -//! use boring::error::ErrorStack; -//! use boring::bn::BigNum; +//! use boring2::error::ErrorStack; +//! use boring2::bn::BigNum; //! //! let an_error = BigNum::from_dec_str("Cannot parse letters"); //! match an_error { diff --git a/boring/src/hash.rs b/boring/src/hash.rs index ba5d7bab..4e5408d6 100644 --- a/boring/src/hash.rs +++ b/boring/src/hash.rs @@ -104,7 +104,7 @@ use self::State::*; /// Calculate a hash in one go: /// /// ``` -/// use boring::hash::{hash, MessageDigest}; +/// use boring2::hash::{hash, MessageDigest}; /// /// let data = b"\x42\xF4\x97\xE0"; /// let spec = b"\x7c\x43\x0f\x17\x8a\xef\xdf\x14\x87\xfe\xe7\x14\x4e\x96\x41\xe2"; @@ -115,7 +115,7 @@ use self::State::*; /// Supply the input in chunks: /// /// ``` -/// use boring::hash::{Hasher, MessageDigest}; +/// use boring2::hash::{Hasher, MessageDigest}; /// /// let data = [b"\x42\xF4", b"\x97\xE0"]; /// let spec = b"\x7c\x43\x0f\x17\x8a\xef\xdf\x14\x87\xfe\xe7\x14\x4e\x96\x41\xe2"; diff --git a/boring/src/memcmp.rs b/boring/src/memcmp.rs index a475a4f6..2ca5e91f 100644 --- a/boring/src/memcmp.rs +++ b/boring/src/memcmp.rs @@ -16,7 +16,7 @@ //! values: //! //! ``` -//! use boring::memcmp::eq; +//! use boring2::memcmp::eq; //! //! // We want to compare `a` to `b` and `c`, without giving //! // away through timing analysis that `c` is more similar to `a` @@ -48,7 +48,7 @@ use libc::size_t; /// values: /// /// ``` -/// use boring::memcmp::eq; +/// use boring2::memcmp::eq; /// /// // We want to compare `a` to `b` and `c`, without giving /// // away through timing analysis that `c` is more similar to `a` diff --git a/boring/src/nid.rs b/boring/src/nid.rs index 11607626..1e8d95a8 100644 --- a/boring/src/nid.rs +++ b/boring/src/nid.rs @@ -34,7 +34,7 @@ pub struct SignatureAlgorithms { /// To view the integer representation of a `Nid`: /// /// ``` -/// use boring::nid::Nid; +/// use boring2::nid::Nid; /// /// assert!(Nid::AES_256_GCM.as_raw() == 901); /// ``` diff --git a/boring/src/pkey.rs b/boring/src/pkey.rs index 1c4012ca..afbdb667 100644 --- a/boring/src/pkey.rs +++ b/boring/src/pkey.rs @@ -29,8 +29,8 @@ //! Generate a 2048-bit RSA public/private key pair and print the public key. //! //! ```rust -//! use boring::rsa::Rsa; -//! use boring::pkey::PKey; +//! use boring2::rsa::Rsa; +//! use boring2::pkey::PKey; //! use std::str; //! //! let rsa = Rsa::generate(2048).unwrap(); diff --git a/boring/src/rand.rs b/boring/src/rand.rs index e5b843e0..ae26f118 100644 --- a/boring/src/rand.rs +++ b/boring/src/rand.rs @@ -5,7 +5,7 @@ //! To generate a buffer with cryptographically strong bytes: //! //! ``` -//! use boring::rand::rand_bytes; +//! use boring2::rand::rand_bytes; //! //! let mut buf = [0; 256]; //! rand_bytes(&mut buf).unwrap(); @@ -25,7 +25,7 @@ use crate::error::ErrorStack; /// To generate a buffer with cryptographically strong bytes: /// /// ``` -/// use boring::rand::rand_bytes; +/// use boring2::rand::rand_bytes; /// /// let mut buf = [0; 256]; /// rand_bytes(&mut buf).unwrap(); diff --git a/boring/src/rsa.rs b/boring/src/rsa.rs index 7bb641fb..3846f210 100644 --- a/boring/src/rsa.rs +++ b/boring/src/rsa.rs @@ -16,7 +16,7 @@ //! Generate a 2048-bit RSA key pair and use the public key to encrypt some data. //! //! ```rust -//! use boring::rsa::{Rsa, Padding}; +//! use boring2::rsa::{Rsa, Padding}; //! //! let rsa = Rsa::generate(2048).unwrap(); //! let data = b"foobar"; diff --git a/boring/src/sha.rs b/boring/src/sha.rs index 98aa26ba..1be5dc47 100644 --- a/boring/src/sha.rs +++ b/boring/src/sha.rs @@ -16,7 +16,7 @@ //! ```rust //! extern crate hex; //! -//! use boring::sha; +//! use boring2::sha; //! //! fn main() { //! let mut hasher = sha::Sha256::new(); @@ -36,7 +36,7 @@ //! ```rust //! extern crate hex; //! -//! use boring::sha::sha256; +//! use boring2::sha::sha256; //! //! fn main() { //! let hash = sha256(b"your data or message"); diff --git a/boring/src/sign.rs b/boring/src/sign.rs index 89e7ba1c..e1920500 100644 --- a/boring/src/sign.rs +++ b/boring/src/sign.rs @@ -10,10 +10,10 @@ //! Sign and verify data given an RSA keypair: //! //! ```rust -//! use boring::sign::{Signer, Verifier}; -//! use boring::rsa::Rsa; -//! use boring::pkey::PKey; -//! use boring::hash::MessageDigest; +//! use boring2::sign::{Signer, Verifier}; +//! use boring2::rsa::Rsa; +//! use boring2::pkey::PKey; +//! use boring2::hash::MessageDigest; //! //! // Generate a keypair //! let keypair = Rsa::generate(2048).unwrap(); diff --git a/boring/src/ssl/mod.rs b/boring/src/ssl/mod.rs index 5a671963..7e704912 100644 --- a/boring/src/ssl/mod.rs +++ b/boring/src/ssl/mod.rs @@ -8,7 +8,7 @@ //! To connect as a client to a remote server: //! //! ```no_run -//! use boring::ssl::{SslMethod, SslConnector}; +//! use boring2::ssl::{SslMethod, SslConnector}; //! use std::io::{Read, Write}; //! use std::net::TcpStream; //! @@ -26,7 +26,7 @@ //! To accept connections as a server from remote clients: //! //! ```no_run -//! use boring::ssl::{SslMethod, SslAcceptor, SslStream, SslFiletype}; +//! use boring2::ssl::{SslMethod, SslAcceptor, SslStream, SslFiletype}; //! use std::net::{TcpListener, TcpStream}; //! use std::sync::Arc; //! use std::thread; diff --git a/boring/src/symm.rs b/boring/src/symm.rs index 1df9a77c..93d5f9e7 100644 --- a/boring/src/symm.rs +++ b/boring/src/symm.rs @@ -5,7 +5,7 @@ //! Encrypt data in AES128 CBC mode //! //! ``` -//! use boring::symm::{encrypt, Cipher}; +//! use boring2::symm::{encrypt, Cipher}; //! //! let cipher = Cipher::aes_128_cbc(); //! let data = b"Some Crypto Text"; @@ -26,8 +26,8 @@ //! Encrypting an asymmetric key with a symmetric cipher //! //! ``` -//! use boring::rsa::{Padding, Rsa}; -//! use boring::symm::Cipher; +//! use boring2::rsa::{Padding, Rsa}; +//! use boring2::symm::Cipher; //! //! // Generate keypair and encrypt private key: //! let keypair = Rsa::generate(2048).unwrap(); @@ -226,7 +226,7 @@ unsafe impl Send for Cipher {} /// CBC mode. /// /// ``` -/// use boring::symm::{Cipher, Mode, Crypter}; +/// use boring2::symm::{Cipher, Mode, Crypter}; /// /// let plaintexts: [&[u8]; 2] = [b"Some Stream of", b" Crypto Text"]; /// let key = b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; @@ -550,7 +550,7 @@ impl Drop for Crypter { /// Encrypt data in AES128 CBC mode /// /// ``` -/// use boring::symm::{encrypt, Cipher}; +/// use boring2::symm::{encrypt, Cipher}; /// /// let cipher = Cipher::aes_128_cbc(); /// let data = b"Some Crypto Text"; @@ -589,7 +589,7 @@ pub fn encrypt( /// Decrypt data in AES128 CBC mode /// /// ``` -/// use boring::symm::{decrypt, Cipher}; +/// use boring2::symm::{decrypt, Cipher}; /// /// let cipher = Cipher::aes_128_cbc(); /// let data = b"\xB4\xB9\xE7\x30\xD6\xD6\xF7\xDE\x77\x3F\x1C\xFF\xB3\x3E\x44\x5A\x91\xD7\x27\x62\ diff --git a/boring/src/x509/extension.rs b/boring/src/x509/extension.rs index 639d28bd..45bd90b6 100644 --- a/boring/src/x509/extension.rs +++ b/boring/src/x509/extension.rs @@ -8,8 +8,8 @@ //! # Example //! //! ```rust -//! use boring::x509::extension::BasicConstraints; -//! use boring::x509::X509Extension; +//! use boring2::x509::extension::BasicConstraints; +//! use boring2::x509::X509Extension; //! //! let mut bc = BasicConstraints::new(); //! let bc = bc.critical().ca().pathlen(1); diff --git a/boring/src/x509/mod.rs b/boring/src/x509/mod.rs index f4a44ee5..2f5706a0 100644 --- a/boring/src/x509/mod.rs +++ b/boring/src/x509/mod.rs @@ -275,16 +275,16 @@ impl X509Builder { /// The `CN` field is used for the common name, such as a DNS name. /// /// ``` - /// use boring::x509::{X509, X509NameBuilder}; + /// use boring2::x509::{X509, X509NameBuilder}; /// - /// let mut x509_name = boring::x509::X509NameBuilder::new().unwrap(); + /// let mut x509_name = boring2::x509::X509NameBuilder::new().unwrap(); /// x509_name.append_entry_by_text("C", "US").unwrap(); /// x509_name.append_entry_by_text("ST", "CA").unwrap(); /// x509_name.append_entry_by_text("O", "Some organization").unwrap(); /// x509_name.append_entry_by_text("CN", "www.example.com").unwrap(); /// let x509_name = x509_name.build(); /// - /// let mut x509 = boring::x509::X509::builder().unwrap(); + /// let mut x509 = boring2::x509::X509::builder().unwrap(); /// x509.set_subject_name(&x509_name).unwrap(); /// ``` #[corresponds(X509_set_subject_name)] diff --git a/boring/src/x509/store.rs b/boring/src/x509/store.rs index 76edac15..0fbbd56c 100644 --- a/boring/src/x509/store.rs +++ b/boring/src/x509/store.rs @@ -6,13 +6,13 @@ //! # Example //! //! ```rust -//! use boring::x509::store::{X509StoreBuilder, X509Store}; -//! use boring::x509::{X509, X509Name}; -//! use boring::asn1::Asn1Time; -//! use boring::pkey::PKey; -//! use boring::hash::MessageDigest; -//! use boring::rsa::Rsa; -//! use boring::nid::Nid; +//! use boring2::x509::store::{X509StoreBuilder, X509Store}; +//! use boring2::x509::{X509, X509Name}; +//! use boring2::asn1::Asn1Time; +//! use boring2::pkey::PKey; +//! use boring2::hash::MessageDigest; +//! use boring2::rsa::Rsa; +//! use boring2::nid::Nid; //! //! let rsa = Rsa::generate(2048).unwrap(); //! let pkey = PKey::from_rsa(rsa).unwrap(); diff --git a/tokio-boring/README.md b/tokio-boring/README.md index 068c881b..62ca8067 100644 --- a/tokio-boring/README.md +++ b/tokio-boring/README.md @@ -25,7 +25,7 @@ async fn main() -> anyhow::Result<()> { let (tcp_stream, _addr) = listener.accept().await?; let server = ssl::SslMethod::tls_server(); - let mut ssl_builder = boring::ssl::SslAcceptor::mozilla_modern(server)?; + let mut ssl_builder = boring2::ssl::SslAcceptor::mozilla_modern(server)?; ssl_builder.set_default_verify_paths()?; ssl_builder.set_verify(ssl::SslVerifyMode::PEER); let acceptor = ssl_builder.build();