Annotation of pgp/src/mpiio.h, revision 1.1.1.8

1.1.1.8 ! root        1: /*     C include file for MPI library I/O routines
        !             2: 
        !             3:        (c) Copyright 1986 by Philip Zimmermann.  All rights reserved.
        !             4:        The author assumes no liability for damages resulting from the use 
        !             5:        of this software, even if the damage results from defects in this 
        !             6:        software.  No warranty is expressed or implied.  
        !             7: 
        !             8:        These routines are for multiprecision arithmetic I/O functions for
        !             9:        number-theoretic cryptographic algorithms such as ElGamal,
        !            10:        Diffie-Hellman, Rabin, or factoring studies for large composite
        !            11:        numbers, as well as Rivest-Shamir-Adleman (RSA) public key
        !            12:        cryptography.
        !            13: 
        !            14:        The external data representation for RSA messages and keys that
        !            15:        some of these library routines assume is outlined in a paper by 
        !            16:        Philip Zimmermann, "A Proposed Standard Format for RSA Cryptosystems",
        !            17:        IEEE Computer, September 1986, Vol. 19 No. 9, pages 21-34.
        !            18:        Some revisions to this data format have occurred since the paper
        !            19:        was published.
        !            20: 
        !            21:        NOTE:  This assumes previous inclusion of "mpilib.h"
        !            22: */
        !            23: 
        !            24: /*--------------------- Byte ordering stuff -------------------*/
        !            25: 
        !            26: /* XLOWFIRST is defined iff external file format is LSB-first byteorder */
        !            27: /* #define XLOWFIRST */ /* defined if external byteorder is LSB-first */
        !            28: 
        !            29: #ifdef NEEDSWAP
        !            30: #undef NEEDSWAP        /* make sure NEEDSWAP is initially undefined */
        !            31: #endif
        !            32: 
        !            33: /* Assume MSB external byte ordering */
        !            34: #ifndef HIGHFIRST
        !            35: #define NEEDSWAP /* External/internal byteorder differs, need byte swap */
        !            36: #endif
        !            37: 
        !            38: 
        !            39: word16 fetch_word16(byte *buf);
        !            40: /*     Fetches a 16-bit word from where byte pointer is pointing.
        !            41:        buf points to external-format byteorder array. */
        !            42: 
        !            43: byte *put_word16(word16 w, byte *buf);
        !            44: /*     Puts a 16-bit word to where byte pointer is pointing, and 
        !            45:        returns updated byte pointer.
        !            46:        buf points to external-format byteorder array. */
        !            47: 
        !            48: word32 fetch_word32(byte *buf);
        !            49: /*     Fetches a 32-bit word from where byte pointer is pointing.
        !            50:        buf points to external-format byteorder array. */
        !            51: 
        !            52: byte *put_word32(word32 w, byte *buf);
        !            53: /*     Puts a 32-bit word to where byte pointer is pointing, and 
        !            54:        returns updated byte pointer.
        !            55:        buf points to external-format byteorder array. */
        !            56: 
        !            57: /*     Note that convert_byteorder does nothing if internal native 
        !            58:        byteorder is already the same as external byteorder. */
        !            59: 
        !            60: #ifdef NEEDSWAP /* External/internal byteorder differs, need byte swap */
        !            61: #define convert_byteorder(buf,bytecount) hiloswap(buf,bytecount)
        !            62: #define mp_convert_order(r) hiloswap(r,units2bytes(global_precision))
        !            63: #else
        !            64: #define convert_byteorder(buf,bytecount)       /* nil statement */
        !            65: #define mp_convert_order(r)    /* nil statement */
        !            66: #endif /* not NEEDSWAP */
        !            67: 
        !            68: /*------------------ End byte ordering stuff -------------------*/
        !            69: 
        !            70: #include <string.h>
        !            71: 
        !            72: #ifdef EMBEDDED
        !            73: int putchar(int c);            /* standard C library function from <stdio.h> */
        !            74: #endif /* EMBEDDED */
        !            75: 
        !            76: int string_length(char *s);
        !            77:        /* Returns string length */
        !            78: 
        !            79: int str2reg(unitptr reg,string digitstr);
        !            80:        /* Converts a possibly-signed digit string into a large binary number.
        !            81:           Returns assumed radix, derived from suffix 'h','o',b','.' */
        !            82: 
        !            83: int display_in_base(string s,unitptr n,short radix);
        !            84:        /* Display n in any base, such as base 10.  Returns number
        !            85:           of digits. */
        !            86: 
        !            87: void mp_display(string s,unitptr r);
        !            88:        /* Display register r in hex, with prefix string s. */
        !            89: 
        !            90: word16 checksum(register byteptr buf, register word16 count);
        !            91:        /* Returns checksum of buffer. */
        !            92: 
        !            93: void cbc_xor(register unitptr dst, register unitptr src, word16 bytecount);
        !            94:        /* Performs the XOR necessary for RSA Cipher Block Chaining. */
        !            95: 
        !            96: void hiloswap(byteptr r1,short numbytes);
        !            97:        /* Reverses the order of bytes in an array of bytes. */
        !            98: 
        !            99: short mpi2reg(register unitptr r, register byteptr buf);
        !           100:        /* Converts to unit array from byte array with bit length prefix
        !           101:           word. */
        !           102: 
        !           103: short reg2mpi(register byteptr buf, register unitptr r);
        !           104:        /* Converts from unit array to byte array with bit length prefix
        !           105:           word. */
        !           106: 
        !           107: /****************** end of MPI I/O library ************************/
        !           108: 

unix.superglobalmegacorp.com

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