RSA BSAFE Cert-C Micro Edition

The power of PKI for the smallest of devices

r_pkey.h File Reference

This file contains structures, defines and function prototypes for public and private key operations.

#include "r_lib.h"
#include "r_types.h"
#include "pk_ids.h"
#include "r_pkey_err.h"
#include "r_format.h"
#include "bio.h"
#include "r_pkey_m.h"

Go to the source code of this file.

Defines

#define R_PKEY_TYPE_UNKNOWN
 Indicates that the PKEY type is unknown.

#define R_PKEY_TYPE_RSA
 Indicates that the PKEY type is RSA.

#define R_PKEY_TYPE_DH
 Indicates that the PKEY type is Diffie-Hellman.

#define R_PKEY_TYPE_DSA
 Indicates that the PKEY type is Digital Signature Algorithm (DSA).

#define R_PKEY_TYPE_ECC
 Indicates that the PKEY type is Elliptic Curve Cryptography (ECC).

#define R_PKEY_FL_DEFAULT
 Indicates default data referencing.

#define R_PKEY_FL_COPY_DATA
 Indicates to copy data.

#define R_PKEY_FL_BY_REFERENCE
 Indicates to use data by reference.

#define R_PKEY_PEM_CIPHER_DES
 Indicates a Privacy Enhanced Mail (PEM) cipher in Data Encryption Standard Cipher Block Chaining (DES CBC) mode.

#define R_PKEY_PEM_CIPHER_DES_EDE
 Indicates a Privacy Enhanced Mail (PEM) cipher in Triple Data Encryption Standard Cipher Block Chaining (DES CBC) mode.

#define R_PKEY_FIELD_ID_RSA_MOD
 Indicates that the data is the modulus (n) of the RSA key. More...

#define R_PKEY_FIELD_ID_RSA_EXP
 Indicates that the data is the public exponent (e) of the RSA key. More...

#define R_PKEY_FIELD_ID_RSA_PRIV_EXP
 Indicates that the data is the private exponent (d) of the RSA key. More...

#define R_PKEY_FIELD_ID_RSA_PRIME_N(n)
 Indicates that the data is the nth prime of the RSA key.

#define R_PKEY_FIELD_ID_RSA_EXP_N(n)
 Indicates that the data is the nth exponent calculation of the RSA key. More...

#define R_PKEY_FIELD_ID_RSA_INV_N(n)
 Indicates that the data is the nth inverse calculation of the RSA key. More...

#define R_PKEY_FIELD_ID_RSA_Q
 Indicates that the data is the first prime (q) of the RSA key.

#define R_PKEY_FIELD_ID_RSA_DMQ1
 Indicates that the data is the first exponent calculation of the RSA key. More...

#define R_PKEY_FIELD_ID_RSA_P
 Indicates that the data is the second prime (p) of the RSA key.

#define R_PKEY_FIELD_ID_RSA_DMP1
 Indicates that the data is the second exponent calculation of the RSA key. More...

#define R_PKEY_FIELD_ID_RSA_IQMP
 Indicates that the data is the second inverse calculation of the RSA key. More...

#define R_PKEY_FIELD_ID_DH_PRIME
 Indicates that the data is the prime parameter of the Diffie-Hellman key. More...

#define R_PKEY_FIELD_ID_DH_GENERATOR
 Indicates that the data is the public key value of the Diffie-Hellman key. More...

#define R_PKEY_FIELD_ID_DH_PUB_KEY
 Indicates that the data is the public key value of the Diffie-Hellman key. More...

#define R_PKEY_FIELD_ID_DSA_PRIME
 Indicates that the data is the prime modulus parameter of the Digital Signature Algorithm (DSA) key. More...

#define R_PKEY_FIELD_ID_DSA_SUBPRIME
 Indicates that the data is the sub-prime/prime divisor parameter of the Digital Signature Algorithm (DSA) key. More...

#define R_PKEY_FIELD_ID_DSA_BASE
 Indicates that the data is the base/generator parameter of the Digital Signature Algorithm (DSA) key. More...

#define R_PKEY_FIELD_ID_DSA_PUB_KEY
 Indicates that the data is the public key value (y) of the Digital Signature Algorithm (DSA) key. More...

#define R_PKEY_FIELD_ID_DSA_PRIV_KEY
 Indicates that the data is the private key value (x) of the Digital Signature Algorithm (DSA) key. More...

#define R_PKEY_INFO_ID_RSA_MOD
 This identifier is used for the retrieval of the RSA modulus associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_RSA_EXP
 This identifier is used for the retrieval of the RSA exponent associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_RSA_PRIV_EXP
 This identifier is used for the retrieval of the RSA private exponent associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_RSA_PRIME_N(n)
 This identifier is used for the retrieval of the nth RSA prime associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_RSA_EXP_N(n)
 This identifier is used for the retrieval of the nth RSA exponent associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_RSA_INV_N(n)
 This identifier is used for the retrieval of the associated RSA inverse associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_RSA_Q
 This identifier is used for the retrieval of the first RSA prime associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_RSA_DMQ1
 This identifier is used for the retrieval of the first RSA exponent associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_RSA_P
 This identifier is used for the retrieval of the second RSA prime associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_RSA_DMP1
 This identifier is used for the retrieval of the second RSA exponent associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_RSA_IQMP
 This identifier is used for the retrieval of the second RSA inverse associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_DH_PRIME
 This identifier is used for the retrieval of the Diffie-Hellman prime value associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_DH_GENERATOR
 This identifier is used for the retrieval of the Diffie-Hellman parameter value associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_DH_PUB_KEY
 This identifier is used for the retrieval of the Diffie-Hellman public key associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_DSA_PRIME
 This identifier is used for the retrieval of the Digital Signature Algorithm (DSA) prime associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_DSA_SUBPRIME
 This identifier is used for the retrieval of the Digital Signature Algorithm (DSA) sub-prime associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_DSA_BASE
 This identifier is used for the retrieval of the Digital Signature Algorithm (DSA) base associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_DSA_PUB_KEY
 This identifier is used for the retrieval of the Digital Signature Algorithm (DSA) public key associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_DSA_PRIV_KEY
 This identifier is used for the retrieval of the Digital Signature Algorithm (DSA) private key associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_R_PKEY_CTX
 This identifier is used for the retrieval of the R_PKEY_CTX associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_R_EITEMS
 This identifier is used for the retrieval of the R_EITEMS associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_FLAG
 This identifier is used for the retrieval of the flags associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_DATA
 This identifier is used for the retrieval of the implementation data associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_REFERENCE
 This identifier is used for the retrieval of the reference count associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_TYPE
 This identifier is used for the retrieval of the R_PKEY_TYPE associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_NUM_BITS
 This identifier is used for the retrieval of the number of bits associated with the R_PKEY. More...

#define R_PKEY_INFO_ID_NUM_PRIMES
 This identifier is used for the retrieval of the number of primes associated with the R_PKEY. More...

#define R_PKEY_CTX_INFO_ID_LIB_CTX
 This identifier is used for the retrieval of the R_LIB_CTX associated with the R_PKEY_CTX. More...

#define R_PKEY_CTX_INFO_ID_R_PKEY_METHOD
 This identifier is used for the retrieval of the R_PKEY_METHOD associated with the R_PKEY_CTX. More...

#define R_PKEY_CTX_INFO_ID_CRYPTO_CTX
 This identifier is used for the retrieval of the cryptographic context associated with the R_PKEY_CTX. More...

#define R_PKEY_CTX_INFO_ID_FLAG
 This identifier is used for the setting or retrieval of the flags associated with the R_PKEY_CTX. More...

#define R_PKEY_CTX_INFO_ID_DATA
 This identifier is used for the setting or retrieval of the extra implementation data associated with the R_PKEY_CTX. More...


Typedefs

typedef int R_PKEY_TYPE
 Indicates the type used to identify an allocated R_PKEY. More...

typedef struct r_pkey_st R_PKEY
 This public key structure can contain both public and/or private key data.

typedef struct r_pkey_method_st R_PKEY_METHOD
 The table of methods for public keys.

typedef struct r_pkey_ctx_st R_PKEY_CTX
 The public key context structure.

typedef int R_PKEY_CB_T (void *arg, int type, R_ITEM *item)
 The callback function to use with R_PKEY_iterate_fields(). More...


Functions

int R_PKEY_CTX_new (R_LIB_CTX *lib_ctx, R_RES_FLAG flag, R_PKEY_TYPE pkeytype, R_PKEY_CTX **pkey_ctx)
 Creates a new R_PKEY_CTX structure. More...

int R_PKEY_CTX_free (R_PKEY_CTX *ctx)
 Removes all allocated memory for the R_PKEY_CTX structure ctx. More...

int R_PKEY_CTX_get_info (R_PKEY_CTX *pkey_ctx, int id, void *param)
 Retrieves information identified by the identifier id from an R_PKEY_CTX. More...

int R_PKEY_CTX_set_info (R_PKEY_CTX *pkey_ctx, int id, void *param)
 Sets information identified by the identifier id against an R_PKEY_CTX. More...

R_LIB_CTXR_PKEY_CTX_get_LIB_CTX (R_PKEY_CTX *ctx)
 Returns the R_LIB_CTX for the R_PKEY_CTX structure ctx. More...

R_PKEY_CTXR_PKEY_get_PKEY_CTX (R_PKEY *pkey)
 Returns the R_PKEY_CTX for the R_PKEY structure pkey. More...

int R_PKEY_get_type (R_PKEY *pkey)
 Returns the type for the asymmetric key pkey. More...

int R_PKEY_new (R_PKEY_CTX *ctx, R_PKEY_TYPE pkeytype, R_PKEY **pkey)
 Creates a new R_PKEY structure pkey. More...

int R_PKEY_free (R_PKEY *pkey)
 Removes all allocated memory for the R_PKEY structure pkey. More...

int R_PKEY_copy (R_PKEY *new_pkey, R_PKEY *pkey, int flag)
 Copies a public key. More...

int R_PKEY_from_binary (R_PKEY_CTX *pkey_ctx, int flag, R_PKEY_TYPE type, size_t max_buf_len, const unsigned char *buf, size_t *consumed_len, R_PKEY **pkey)
 Creates an R_PKEY structure from the specified binary data in ASN.1 format indicated by buf with a length of max_buf_len. More...

int R_PKEY_to_binary (R_PKEY *pkey, size_t max_buf_len, unsigned char *buf, size_t *consumed_len)
 Creates binary Basic Encoding Rules (BER)/Distinguished Encoding Rules (DER) encoded data from the specified R_PKEY structure and places the binary output in buf. More...

int R_PKEY_from_public_key_binary (R_PKEY_CTX *pkey_ctx, int flag, R_PKEY_TYPE type, size_t max_buf_len, const unsigned char *buf, size_t *consumed_len, R_PKEY **pkey)
 Creates a new R_PKEY structure from the public key component of the binary data buf. More...

int R_PKEY_to_public_key_binary (R_PKEY *pkey, size_t max_buf_len, unsigned char *buf, size_t *out_len)
 Creates the binary data of the public key component of an R_PKEY structure pkey. More...

int R_PKEY_reference_inc (R_PKEY *pkey)
 Increments the reference count for the specified R_PKEY structure pkey. More...

int R_PKEY_cmp (R_PKEY *key1, R_PKEY *key2)
 Compares two keys key1 and key2. More...

int R_PKEY_public_cmp (R_PKEY *key1, R_PKEY *key2)
 Compares the public components of two keys key1 and key2. More...

int R_PKEY_get_info (R_PKEY *pkey, int id, void *param)
 Returns identified data for the R_PKEY pkey. More...

int R_PKEY_set_info (R_PKEY *pkey, int type, void *param)
 Sets data for the R_PKEY pkey. More...

int R_PKEY_iterate_fields (R_PKEY *pkey, R_PKEY_CB_T *func, void *arg)
 Applies the callback function func with callback argument arg to each field in the key pkey. More...

int R_PKEY_get_num_bits (R_PKEY *pkey)
 Returns the number of bits in an asymmetric key for the R_PKEY structure pkey. More...

int R_PKEY_get_num_primes (R_PKEY *pkey)
 Returns the number of primes contained in the RSA private key for the R_PKEY structure pkey. More...

int R_PKEY_generate_simple (R_PKEY_CTX *pkey_ctx, R_PKEY **rpkey, int type, int num_bits, int modifier, int flags, R_SURRENDER *surrender)
 Generates a new public/private key pair pkey. More...

int R_PKEY_from_file (R_PKEY_CTX *pkey_ctx, R_PKEY **pkey, char *filename, int type, R_FORMAT format)
 Creates an R_PKEY structure from the specified private key binary data in ASN.1 format indicated by filename with a private key type type. More...

int R_PKEY_TYPE_to_string (R_PKEY_TYPE type, size_t max_str_len, char *str)
 Returns the key type string for the key type type. More...

int R_PKEY_TYPE_from_string (R_PKEY_TYPE *type, char *str)
 Returns the key type for the string str. More...

int R_PKEY_to_bio (BIO *bio, R_PKEY *pkey, R_FORMAT format, char *cipher)
 Outputs the R_PKEY structure pkey to the bio in the format specified by format. More...

int R_PKEY_print (BIO *bio, R_PKEY *pkey, R_FORMAT format, char *format_arg)
 Prints an R_PKEY structure from the specified binary data in ASN.1 format indicated by bio with a format of format and format arguments format_arg. More...

int R_PKEY_from_bio (BIO *bio, R_PKEY_CTX *pkey_ctx, R_PKEY **pkey, int type, R_FORMAT format)
 Creates an R_PKEY structure from the specified private key binary data in ASN.1 format indicated by bio with a format of format. More...


Copyright (c) 1999-2002 RSA Security Inc. All rights reserved. 061-001005-150-001-000-3768 - 1.5