tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

keyi.h (2729B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef _KEYI_H_
      6 #define _KEYI_H_
      7 #include "secerr.h"
      8 
      9 SEC_BEGIN_PROTOS
     10 /* NSS private functions */
     11 /* map an oid to a keytype... actually this function and it's converse
     12 *  are good candidates for public functions..  */
     13 KeyType seckey_GetKeyType(SECOidTag pubKeyOid);
     14 
     15 /*
     16 * Pulls the hash algorithm, signing algorithm, and key type out of a
     17 * composite algorithm.
     18 *
     19 * key: pointer to the public key. Should be NULL if called for a sign operation.
     20 * sigAlg: the composite algorithm to dissect.
     21 * hashalg: address of a SECOidTag which will be set with the hash algorithm.
     22 * encalg: address of a SECOidTag which will be set with the signing alg.
     23 * mechp: address of a PCKS #11 Mechanism which will be set to the
     24 *  combined hash/encrypt mechanism. If set to CKM_INVALID_MECHANISM, the code
     25 *  will fall back to external hashing.
     26 * mechparams: address of a SECItem will set to the parameters for the combined
     27 *  hash/encrypt mechanism.
     28 *
     29 * Returns: SECSuccess if the algorithm was acceptable, SECFailure if the
     30 *  algorithm was not found or was not a signing algorithm.
     31 */
     32 SECStatus sec_DecodeSigAlg(const SECKEYPublicKey *key, SECOidTag sigAlg,
     33                           const SECItem *param, SECOidTag *encalg,
     34                           SECOidTag *hashalg, CK_MECHANISM_TYPE *mech,
     35                           SECItem *mechparams);
     36 
     37 /* just get the 'encryption' oid from the combined signature oid */
     38 SECOidTag sec_GetEncAlgFromSigAlg(SECOidTag sigAlg);
     39 
     40 /* extract the RSA-PSS hash algorithms and salt length from
     41 * parameters, taking into account of the default implications.
     42 *
     43 * (parameters is the parameters field of a algorithm ID structure
     44 * (SECAlgorithmID)*/
     45 SECStatus sec_DecodeRSAPSSParams(PLArenaPool *arena,
     46                                 const SECItem *params,
     47                                 SECOidTag *hashAlg,
     48                                 SECOidTag *maskHashAlg,
     49                                 unsigned long *saltLength);
     50 
     51 /* convert the encoded RSA-PSS parameters into PKCS #11 mechanism parameters */
     52 SECStatus sec_DecodeRSAPSSParamsToMechanism(PLArenaPool *arena,
     53                                            const SECItem *params,
     54                                            CK_RSA_PKCS_PSS_PARAMS *mech,
     55                                            SECOidTag *hashAlg);
     56 
     57 /* get the parameter set, converted to a key oid, only for new keys like mldsa, mlkem, and shldsa */
     58 SECOidTag seckey_GetParameterSet(const SECKEYPrivateKey *key);
     59 SEC_END_PROTOS
     60 
     61 #endif /* _KEYHI_H_ */