blapi.h
来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C头文件 代码 · 共 742 行 · 第 1/2 页
H
742 行
/* * crypto.h - public data structures and prototypes for the crypto library * * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is the Netscape security libraries. * * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1994-2000 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL"), in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient * may use your version of this file under either the MPL or the * GPL. * * $Id: blapi.h,v 1.4 2000/07/21 20:50:31 nelsonb%netscape.com Exp $ */#ifndef _BLAPI_H_#define _BLAPI_H_#include "blapit.h"SEC_BEGIN_PROTOS/*** RSA encryption/decryption. When encrypting/decrypting the output** buffer must be at least the size of the public key modulus.*//*** Generate and return a new RSA public and private key.** Both keys are encoded in a single RSAPrivateKey structure.** "cx" is the random number generator context** "keySizeInBits" is the size of the key to be generated, in bits.** 512, 1024, etc.** "publicExponent" when not NULL is a pointer to some data that** represents the public exponent to use. The data is a byte** encoded integer, in "big endian" order.*/extern RSAPrivateKey *RSA_NewKey(int keySizeInBits, SECItem * publicExponent);/*** Perform a raw public-key operation ** Length of input and output buffers are equal to key's modulus len.*/extern SECStatus RSA_PublicKeyOp(RSAPublicKey * key, unsigned char * output, unsigned char * input);/*** Perform a raw private-key operation ** Length of input and output buffers are equal to key's modulus len.*/extern SECStatus RSA_PrivateKeyOp(RSAPrivateKey * key, unsigned char * output, unsigned char * input);/********************************************************************** DSA signing algorithm*//*** Generate and return a new DSA public and private key pair,** both of which are encoded into a single DSAPrivateKey struct.** "params" is a pointer to the PQG parameters for the domain** Uses a random seed.*/extern SECStatus DSA_NewKey(PQGParams * params, DSAPrivateKey ** privKey);/* signature is caller-supplied buffer of at least 20 bytes.** On input, signature->len == size of buffer to hold signature.** digest->len == size of digest.** On output, signature->len == size of signature in buffer.** Uses a random seed.*/extern SECStatus DSA_SignDigest(DSAPrivateKey * key, SECItem * signature, SECItem * digest);/* signature is caller-supplied buffer of at least 20 bytes.** On input, signature->len == size of buffer to hold signature.** digest->len == size of digest.*/extern SECStatus DSA_VerifyDigest(DSAPublicKey * key, SECItem * signature, SECItem * digest);/* For FIPS compliance testing. Seed must be exactly 20 bytes long */extern SECStatus DSA_NewKeyFromSeed(PQGParams *params, unsigned char * seed, DSAPrivateKey **privKey);/* For FIPS compliance testing. Seed must be exactly 20 bytes. */extern SECStatus DSA_SignDigestWithSeed(DSAPrivateKey * key, SECItem * signature, SECItem * digest, unsigned char * seed);/******************************************************** Diffie Helman key exchange algorithm *//* Generates parameters for Diffie-Helman key generation.** primeLen is the length in bytes of prime P to be generated.*/extern SECStatus DH_GenParam(int primeLen, DHParams ** params);/* Generates a public and private key, both of which are encoded in a single** DHPrivateKey struct. Params is input, privKey are output. ** This is Phase 1 of Diffie Hellman.*/extern SECStatus DH_NewKey(DHParams * params, DHPrivateKey ** privKey);/* ** DH_Derive does the Diffie-Hellman phase 2 calculation, using the ** other party's publicValue, and the prime and our privateValue.** maxOutBytes is the requested length of the generated secret in bytes. ** A zero value means produce a value of any length up to the size of ** the prime. If successful, derivedSecret->data is set ** to the address of the newly allocated buffer containing the derived ** secret, and derivedSecret->len is the size of the secret produced.** The size of the secret produced will never be larger than the length** of the prime, and it may be smaller than maxOutBytes.** It is the caller's responsibility to free the allocated buffer ** containing the derived secret.*/extern SECStatus DH_Derive(SECItem * publicValue, SECItem * prime, SECItem * privateValue, SECItem * derivedSecret, unsigned int maxOutBytes);/* ** KEA_CalcKey returns octet string with the private key for a dual** Diffie-Helman key generation as specified for government key exchange.*/extern SECStatus KEA_Derive(SECItem *prime, SECItem *public1, SECItem *public2, SECItem *private1, SECItem *private2, SECItem *derivedSecret);/* * verify that a KEA or DSA public key is a valid key for this prime and * subprime domain. */extern PRBool KEA_Verify(SECItem *Y, SECItem *prime, SECItem *subPrime);/******************************************//*** RC4 symmetric stream cypher*//*** Create a new RC4 context suitable for RC4 encryption/decryption.** "key" raw key data** "len" the number of bytes of key data*/extern RC4Context *RC4_CreateContext(unsigned char *key, int len);/*** Destroy an RC4 encryption/decryption context.** "cx" the context** "freeit" if PR_TRUE then free the object as well as its sub-objects*/extern void RC4_DestroyContext(RC4Context *cx, PRBool freeit);/*** Perform RC4 encryption.** "cx" the context** "output" the output buffer to store the encrypted data.** "outputLen" how much data is stored in "output". Set by the routine** after some data is stored in output.** "maxOutputLen" the maximum amount of data that can ever be** stored in "output"** "input" the input data** "inputLen" the amount of input data*/extern SECStatus RC4_Encrypt(RC4Context *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen);/*** Perform RC4 decryption.** "cx" the context** "output" the output buffer to store the decrypted data.** "outputLen" how much data is stored in "output". Set by the routine** after some data is stored in output.** "maxOutputLen" the maximum amount of data that can ever be** stored in "output"** "input" the input data** "inputLen" the amount of input data*/extern SECStatus RC4_Decrypt(RC4Context *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen);/******************************************//*** RC2 symmetric block cypher*//*** Create a new RC2 context suitable for RC2 encryption/decryption.** "key" raw key data** "len" the number of bytes of key data** "iv" is the CBC initialization vector (if mode is NSS_RC2_CBC)** "mode" one of NSS_RC2 or NSS_RC2_CBC** "effectiveKeyLen" is the effective key length (as specified in ** RFC 2268) in bytes (not bits).**** When mode is set to NSS_RC2_CBC the RC2 cipher is run in "cipher block** chaining" mode.*/extern RC2Context *RC2_CreateContext(unsigned char *key, unsigned int len, unsigned char *iv, int mode, unsigned effectiveKeyLen);/*** Destroy an RC2 encryption/decryption context.** "cx" the context** "freeit" if PR_TRUE then free the object as well as its sub-objects*/extern void RC2_DestroyContext(RC2Context *cx, PRBool freeit);/*** Perform RC2 encryption.** "cx" the context** "output" the output buffer to store the encrypted data.** "outputLen" how much data is stored in "output". Set by the routine** after some data is stored in output.** "maxOutputLen" the maximum amount of data that can ever be** stored in "output"** "input" the input data** "inputLen" the amount of input data*/extern SECStatus RC2_Encrypt(RC2Context *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, unsigned char *input, unsigned int inputLen);/*** Perform RC2 decryption.** "cx" the context** "output" the output buffer to store the decrypted data.** "outputLen" how much data is stored in "output". Set by the routine** after some data is stored in output.** "maxOutputLen" the maximum amount of data that can ever be** stored in "output"** "input" the input data** "inputLen" the amount of input data*/extern SECStatus RC2_Decrypt(RC2Context *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, unsigned char *input, unsigned int inputLen);/******************************************//*** RC5 symmetric block cypher -- 64-bit block size*//*** Create a new RC5 context suitable for RC5 encryption/decryption.** "key" raw key data** "len" the number of bytes of key data** "iv" is the CBC initialization vector (if mode is NSS_RC5_CBC)** "mode" one of NSS_RC5 or NSS_RC5_CBC**** When mode is set to NSS_RC5_CBC the RC5 cipher is run in "cipher block** chaining" mode.*/extern RC5Context *RC5_CreateContext(SECItem *key, unsigned int rounds, unsigned int wordSize, unsigned char *iv, int mode);/*** Destroy an RC5 encryption/decryption context.** "cx" the context** "freeit" if PR_TRUE then free the object as well as its sub-objects*/extern void RC5_DestroyContext(RC5Context *cx, PRBool freeit);/*** Perform RC5 encryption.** "cx" the context** "output" the output buffer to store the encrypted data.** "outputLen" how much data is stored in "output". Set by the routine** after some data is stored in output.** "maxOutputLen" the maximum amount of data that can ever be** stored in "output"** "input" the input data** "inputLen" the amount of input data*/extern SECStatus RC5_Encrypt(RC5Context *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, unsigned char *input, unsigned int inputLen);/*** Perform RC5 decryption.** "cx" the context** "output" the output buffer to store the decrypted data.** "outputLen" how much data is stored in "output". Set by the routine** after some data is stored in output.** "maxOutputLen" the maximum amount of data that can ever be** stored in "output"** "input" the input data** "inputLen" the amount of input data*/extern SECStatus RC5_Decrypt(RC5Context *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, unsigned char *input, unsigned int inputLen);/******************************************//*** DES symmetric block cypher*//*** Create a new DES context suitable for DES encryption/decryption.** "key" raw key data** "len" the number of bytes of key data** "iv" is the CBC initialization vector (if mode is NSS_DES_CBC or** mode is DES_EDE3_CBC)** "mode" one of NSS_DES, NSS_DES_CBC, NSS_DES_EDE3 or NSS_DES_EDE3_CBC** "encrypt" is PR_TRUE if the context will be used for encryption**** When mode is set to NSS_DES_CBC or NSS_DES_EDE3_CBC then the DES** cipher is run in "cipher block chaining" mode.*/extern DESContext *DES_CreateContext(unsigned char *key, unsigned char *iv, int mode, PRBool encrypt);/*** Destroy an DES encryption/decryption context.** "cx" the context** "freeit" if PR_TRUE then free the object as well as its sub-objects*/extern void DES_DestroyContext(DESContext *cx, PRBool freeit);/*** Perform DES encryption.** "cx" the context** "output" the output buffer to store the encrypted data.** "outputLen" how much data is stored in "output". Set by the routine
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?