Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quellcode-Bibliothek ec.rs

  Sprache: Rust
 

            pkcs11_bindings::CKM_SHA512_HMAC,
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

OID

use
 x86 
    .into_result
};

// use std::ptr::null;
// use std::ptr::null_mut;
use crate::{
    /* RFC
};
    init
    p11::{
        KU_ALL,java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 2
 PK11_ImportPublicKeyPK11_PubDeriveWithKDF,
        PK11_ReadRawAttribute, PK11ObjectType::    der::write_tag_and_length(&mut out, der::TAG_OBJECT_IDlen)?java.lang.StringIndexOutOfBoundsException: Range [71, 37) out of bounds for length 37
        ,Slot
    },
    ssl::PRBool,
    util::SECItemMut,
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 2
//
// Constants
//

#[derive(Clone, Debug, Eq, PartialEq)]
pub:>java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 55
    P256
    P384,
    E:= .private_key.as_mut().ok_or(Error::InvalidI
    X25519,
    java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
}

java.lang.StringIndexOutOfBoundsException: Range [15, 10) out of bounds for length 15
 typejava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 37

 EcdhKeypair
    pub
    pub private:/java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 2
}    java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 12

#[java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 43
pub();

impl Ecdh {
    [java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
  fn(urve >Selfjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
        )
    s 

      java.lang.StringIndexOutOfBoundsException: Range [33, 27) out of bounds for length 76
     ecdh_keygen)
    }    public_keyjava.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 38
-<,E>           *lot,

// Object identifiers in DER tag-length-value form
pub const java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 16
     5480 iecPublicKey) */
    0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01,
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
pubCK_FALSEinto(,
    /* RFC 5480 (secp256r1) */
    0
].(;
pub const OID_SECP384R1_BYTES: &[u8]java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    /* RFC 5480 (secp384r1) */java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
    0x86 x,0 java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
];
 constjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 5
    ) */
    0x2a, }
];

(?
pubjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 5
    *java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 44
0 x *,ptr:java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 80
]java.lang.StringIndexOutOfBoundsException: Range [3, 2) out of bounds for length 2

pub const OID_X25519_BYTES: &[u8] = &[
#java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 34
     ...*
    0x2b, 0x06, java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 69
;

java.lang.StringIndexOutOfBoundsException: Range [28, 3) out of bounds for length 32
let  :der:+len)java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
_ID, len())?;
    out.extend_from_slicer Err(java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 44
    java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 1
}

fn (java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
    match {
        EcCurve::X25519    let mut der_pki = SECItemBorrowed:p);
       EcCurve:Ed25519 = to_vec(,
        EcCurve::P256 => OID_SECP256R1_BYTES.to_vec(),
        EcCurve::P384 => OID_SECP384R1_BYTES.to_vec(),
        java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}

const fn ec_curve_to_ckm(alg: &const fn ec_curve_to_ckm(alg: &EcCurve,
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 28
        EcCurve::P256 | EcCurve::P384 | EcCurve::P521 => CKM_EC_KEY_PAIR_GEN,
        EcCurve::Ed25519 => CKM_EC_EDWARDS_KEY_PAIR_GENptr::null_mut(,
        EcCurve::X25519 => CKM_EC_MONTGOMERY_KEY_PAIR_GEN,
    }
}

//
// Curve functions
//

pub fn java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
    );

    
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    let oid_bytes = object_id(&curve_oid)?;
    mut=::wrap(?java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
    let {

    // Get the Mechanism based on the Curve and its use
=java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 37

    
     ecdhs:& : & Resultu8,  {

    // Create a pointer for the public key
    leti(?java.lang.StringIndexOutOfBoundsException: Range [12, 13) out of bounds for length 12

    // https://github.com/mozilla/nss-gk-api/issues/1
    unsafe {
        let sk = java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 14
                        java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 46
            ckm,
            oid_ptr.:java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 38
            raw pk_ptr
      java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 28
            CK_FALSE.into(),
            java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 28
        )
        .into_result()?;

tpk java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 50

        let kp = EcdhKeypair {
            public: pk,
            private: sk,
        }java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10

        Ok -> <<u8> >{
    }
}

pub fn export_ec_private_key_pkcs8(key: &PrivateKey) - nit(?java.lang.StringIndexOutOfBoundsException: Range [12, 13) out of bounds for length 12
    init()?;
    unsafe {
        let sk: crate::ScopedSECItem
(*key,:).(?;
        Ok(sk.into_vec())
    }
}

pub fn import_ec_public_key_from_spki(spki: &[u8]) -> Result<PublicKey, java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 64
    init()?;
    let     {
spki_item_ptr  .as_mut)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
                .)ok_or(::)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
    unsafe {
        let spki = SECKEY_DecodeDERSubjectPublicKeyInfo(spki_item_ptr).into_result            (java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
        Osignature)
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 1
                .allow(clippy::useless_conversion)]

        let handle = pub fn sign_ecdsa(private_key: &PrivateKey, data: &[    sign(private_key, data, crate::p11::CKM_ECDSA.into
        if handle == pkcs11_bindings::CK_INVALID_HANDLE {
            return Err(Error::InvalidInput);
        }

        Ok(pkac:java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 34
   }
}

pub fn import_ec_private_key_pkcs8(java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 57
    init

    // Get the PKCS11 slot
   letslot =:)?
    let data: &u8]
sjava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 21

    // Create a pointer for the private key
    et =:(;

    unsafe {
        secstatus_to_res(let mut signature = SECItemBorrowed?;
            s,
            public_keyas_mut(.ok_or(Error::InvalidInput)?,
            mut(,
            ptr::null_mut(),
            0,
            0,
            KU_ALL,
            &raw mut             ptr::null_mut()
            ptr::
                match rv {

        let sk = _=>Ok(false,
    sk)
    }
}

pub fn export_ec_private_key_from_raw
    init()?;
    let mut key_item java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
        verify(public_key data,signature,crate::::CKM_ECDSA.nto(java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
    }
    Ok(#[allow(clippy:useless_conversion)]
}

pub fn ecdh(sk: &PrivateKey, pk: &PublicKey) -> Result<Vec<u8>, Error> {
    init()?;
    let sym_key   java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
        PK11_PubDeriveWithKDF(
            sk.cast(),
            pk.cast(),
            0,
            ptr::null_mut(),
            ptr::null_mut(),
            pkcs11_bindings::CKM_ECDH1_DERIVE,
            pkcs11_bindings::CKM_SHA512_HMAC,
            pkcs11_bindings::CKA_SIGN,
            0,
            pkcs11_bindings::CKD_NULL,
            ptr::null_mut(),
            ptr::null_mut(),
        )
        .into_result()?
    };

    let key = sym_key.key_data()?;
    Ok(key.to_vec())
}

pub fn convert_to_public(sk: &PrivateKey) -> Result<PublicKey, Error> {
    init()?;
    unsafe {
        let pk = crate::p11::SECKEY_ConvertToPublicKey(**sk).into_result()?;
        Ok(pk)
    }
}

pub fn sign(
    private_key: &PrivateKey,
    data: &[u8],
    mechanism: std::os::raw::c_ulong,
) -> Result<Vec<u8>, Error> {
    init()?;
    let data_signature = vec![0u8; 0x40];

    let mut data_to_sign = SECItemBorrowed::wrap(data)?;
    let mut signature = SECItemBorrowed::wrap(&data_signature)?;
    unsafe {
        secstatus_to_res(crate::p11::PK11_SignWithMechanism(
            private_key.as_mut().ok_or(Error::InvalidInput)?,
            mechanism,
            ptr::null_mut(),
            signature.as_mut(),
            data_to_sign.as_mut(),
        ))?;

        let signature = signature.as_slice().to_vec();
        Ok(signature)
    }
}

#[allow(clippy::allow_attributes)]
#[allow(clippy::useless_conversion)]
pub fn sign_ecdsa(private_key: &PrivateKey, data: &[u8]) -> Result<Vec<u8>, Error> {
    sign(private_key, data, crate::p11::CKM_ECDSA.into())
}

#[allow(clippy::allow_attributes)]
#[allow(clippy::useless_conversion)]
pub fn sign_eddsa(private_key: &PrivateKey, data: &[u8]) -> Result<Vec<u8>, Error> {
    sign(private_key, data, crate::p11::CKM_EDDSA.into())
}

pub fn verify(
    public_key: &PublicKey,
    data: &[u8],
    signature: &[u8],
    mechanism: std::os::raw::c_ulong,
) -> Result<bool, Error> {
    init()?;
    unsafe {
        let mut data_to_sign = SECItemBorrowed::wrap(data)?;
        let mut signature = SECItemBorrowed::wrap(signature)?;

        let rv = crate::p11::PK11_VerifyWithMechanism(
            public_key.as_mut().ok_or(Error::InvalidInput)?,
            mechanism,
            ptr::null_mut(),
            signature.as_mut(),
            data_to_sign.as_mut(),
            ptr::null_mut(),
        );

        match rv {
            0 => Ok(true),
            _ => Ok(false),
        }
    }
}

#[allow(clippy::allow_attributes)]
#[allow(clippy::useless_conversion)]
pub fn verify_ecdsa(public_key: &PublicKey, data: &[u8], signature: &[u8]) -> Result<bool, Error> {
    verify(public_key, data, signature, crate::p11::CKM_ECDSA.into())
}

#[allow(clippy::allow_attributes)]
#[allow(clippy::useless_conversion)]
pub fn verify_eddsa(public_key: &PublicKey, data: &[u8], signature: &[u8]) -> Result<bool, Error> {
    verify(public_key, data, signature, crate::p11::CKM_EDDSA.into())
}

Messung V0.5 in Prozent
C=91 H=91 G=90

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.7Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=141584
#Domains=752002