Annotation of rsaref/source/rsaref.h, revision 1.1.1.1

1.1       root        1: /* RSAREF.H - header file for RSAREF cryptographic toolkit
                      2:  */
                      3: 
                      4: /* Copyright (C) 1991-2 RSA Laboratories, a division of RSA Data
                      5:    Security, Inc. All rights reserved.
                      6:  */
                      7: 
                      8: /* Message-digest algorithms.
                      9:  */
                     10: #define DA_MD2 3
                     11: #define DA_MD5 5
                     12: 
                     13: /* RSA key lengths.
                     14:  */
                     15: #define MIN_RSA_MODULUS_BITS 508
                     16: #define MAX_RSA_MODULUS_BITS 1024
                     17: #define MAX_RSA_MODULUS_LEN ((MAX_RSA_MODULUS_BITS + 7) / 8)
                     18: #define MAX_RSA_PRIME_BITS ((MAX_RSA_MODULUS_BITS + 1) / 2)
                     19: #define MAX_RSA_PRIME_LEN ((MAX_RSA_PRIME_BITS + 7) / 8)
                     20: 
                     21: /* Maximum lengths of encoded and encrypted content, as a function of
                     22:    content length len. Also, inverse functions.
                     23:  */
                     24: #define ENCODED_CONTENT_LEN(len) (4*(len)/3 + 3)
                     25: #define ENCRYPTED_CONTENT_LEN(len) ENCODED_CONTENT_LEN ((len)+8)
                     26: #define DECODED_CONTENT_LEN(len) (3*(len)/4 + 1)
                     27: #define DECRYPTED_CONTENT_LEN(len) DECODED_CONTENT_LEN ((len)-1)
                     28: 
                     29: /* Maximum lengths of signatures, encrypted keys, encrypted
                     30:    signatures, and message digests.
                     31:  */
                     32: #define MAX_SIGNATURE_LEN MAX_RSA_MODULUS_LEN
                     33: #define MAX_PEM_SIGNATURE_LEN ENCODED_CONTENT_LEN (MAX_SIGNATURE_LEN)
                     34: #define MAX_PEM_ENCRYPTED_KEY_LEN ENCODED_CONTENT_LEN (MAX_RSA_MODULUS_LEN)
                     35: #define MAX_PEM_ENCRYPTED_SIGNATURE_LEN \
                     36:   ENCRYPTED_CONTENT_LEN (MAX_SIGNATURE_LEN)
                     37: #define MAX_DIGEST_LEN 16
                     38: 
                     39: /* Error codes.
                     40:  */
                     41: #define RE_CONTENT_ENCODING 0x0400
                     42: #define RE_DATA 0x0401
                     43: #define RE_DIGEST_ALGORITHM 0x0402
                     44: #define RE_ENCODING 0x0403
                     45: #define RE_KEY 0x0404
                     46: #define RE_KEY_ENCODING 0x0405
                     47: #define RE_LEN 0x0406
                     48: #define RE_MODULUS_LEN 0x0407
                     49: #define RE_NEED_RANDOM 0x0408
                     50: #define RE_PRIVATE_KEY 0x0409
                     51: #define RE_PUBLIC_KEY 0x040a
                     52: #define RE_SIGNATURE 0x040b
                     53: #define RE_SIGNATURE_ENCODING 0x040c
                     54: 
                     55: /* Random structure.
                     56:  */
                     57: typedef struct {
                     58:   unsigned int bytesNeeded;
                     59:   unsigned char state[16];
                     60:   unsigned int outputAvailable;
                     61:   unsigned char output[16];
                     62: } R_RANDOM_STRUCT;
                     63: 
                     64: /* RSA public and private key.
                     65:  */
                     66: typedef struct {
                     67:   unsigned int bits;                           /* length in bits of modulus */
                     68:   unsigned char modulus[MAX_RSA_MODULUS_LEN];                    /* modulus */
                     69:   unsigned char exponent[MAX_RSA_MODULUS_LEN];           /* public exponent */
                     70: } R_RSA_PUBLIC_KEY;
                     71: 
                     72: typedef struct {
                     73:   unsigned int bits;                           /* length in bits of modulus */
                     74:   unsigned char modulus[MAX_RSA_MODULUS_LEN];                    /* modulus */
                     75:   unsigned char publicExponent[MAX_RSA_MODULUS_LEN];     /* public exponent */
                     76:   unsigned char exponent[MAX_RSA_MODULUS_LEN];          /* private exponent */
                     77:   unsigned char prime[2][MAX_RSA_PRIME_LEN];               /* prime factors */
                     78:   unsigned char primeExponent[2][MAX_RSA_PRIME_LEN];   /* exponents for CRT */
                     79:   unsigned char coefficient[MAX_RSA_PRIME_LEN];          /* CRT coefficient */
                     80: } R_RSA_PRIVATE_KEY;
                     81: 
                     82: /* RSA prototype key.
                     83:  */
                     84: typedef struct {
                     85:   unsigned int bits;                           /* length in bits of modulus */
                     86:   int useFermat4;                        /* public exponent (1 = F4, 0 = 3) */
                     87: } R_RSA_PROTO_KEY;
                     88: 
                     89: /* Random structures.
                     90:  */
                     91: int R_RandomInit PROTO_LIST ((R_RANDOM_STRUCT *));
                     92: int R_RandomUpdate PROTO_LIST
                     93:   ((R_RANDOM_STRUCT *, unsigned char *, unsigned int));
                     94: int R_GetRandomBytesNeeded PROTO_LIST ((unsigned int *, R_RANDOM_STRUCT *));
                     95: void R_RandomFinal PROTO_LIST ((R_RANDOM_STRUCT *));
                     96: 
                     97: /* Cryptographic enhancements.
                     98:  */
                     99: int R_SignPEMBlock PROTO_LIST
                    100:   ((unsigned char *, unsigned int *, unsigned char *, unsigned int *,
                    101:     unsigned char *, unsigned int, int, int, R_RSA_PRIVATE_KEY *));
                    102: int R_VerifyPEMSignature PROTO_LIST
                    103:   ((unsigned char *, unsigned int *, unsigned char *, unsigned int,
                    104:     unsigned char *, unsigned int, int, int, R_RSA_PUBLIC_KEY *));
                    105: int R_VerifyBlockSignature PROTO_LIST
                    106:   ((unsigned char *, unsigned int, unsigned char *, unsigned int, int,
                    107:     R_RSA_PUBLIC_KEY *));
                    108: int R_SealPEMBlock PROTO_LIST
                    109:   ((unsigned char *, unsigned int *, unsigned char *, unsigned int *,
                    110:     unsigned char *, unsigned int *, unsigned char [8], unsigned char *,
                    111:     unsigned int, int, R_RSA_PUBLIC_KEY *, R_RSA_PRIVATE_KEY *,
                    112:     R_RANDOM_STRUCT *));
                    113: int R_OpenPEMBlock PROTO_LIST 
                    114:   ((unsigned char *, unsigned int *, unsigned char *, unsigned int,
                    115:     unsigned char *, unsigned int, unsigned char *, unsigned int,
                    116:     unsigned char [8], int, R_RSA_PRIVATE_KEY *, R_RSA_PUBLIC_KEY *));
                    117: int R_DigestBlock PROTO_LIST 
                    118:   ((unsigned char *, unsigned int *, unsigned char *, unsigned int, int));
                    119:   
                    120: /* Key-pair generation.
                    121:  */
                    122: int R_GeneratePEMKeys PROTO_LIST
                    123:   ((R_RSA_PUBLIC_KEY *, R_RSA_PRIVATE_KEY *, R_RSA_PROTO_KEY *,
                    124:     R_RANDOM_STRUCT *));
                    125: 
                    126: /* Routines supplied by the implementor.
                    127:  */
                    128: void R_memset PROTO_LIST ((POINTER, int, unsigned int));
                    129: void R_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
                    130: int R_memcmp PROTO_LIST ((POINTER, POINTER, unsigned int));

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.