/ ***************** 88ssleay: a cryptographic kitchen sink. ********************************* ******************
/ ********** Basic algorithm ************** 1, The General Ciphers and Message Digests Supported: MD2, MD5, SHA (Secure Hash Algorithm), Sha1des, RC4 (Stream Cipher), Idea --- 2, Public Key Crypto Systems. (BiG Number): Ras DH Sit On Top of Bn.rs: Conform To PKCS # 1DH: hiffie-hellman protocol = pkcs333, rand: psuedo-random number. Based ON MD5. *************************************** ***************** /
/ ************ High-level interface ******** EVP: Digital Envelope library, including 17 encryption and 4 information summary. Includes Base64 lib.pem: private enhanced email. Encoded electronic package data. Preparation with ASCII, use base64 encoded PKCS7: Another encoded electronic package data, use ASN.1 encoding
------------ Encode Data Structures.asn1: used by x509 and pkcsx509: PKCS7OBJ: Object Identifiers ------- Meth: Push 'Methods' of Retrieving Certificates Into the Library
***************************** /
/ *********** RELY ON 'Complex' Data Structures *************** LHASH: Stack: buft_db: a Simple Memory Based Text File Data Base. Can Specify Unique Indexes.conf: Configuration File.
Err: Error Report. ************************************************************ *********************************************************** *
sink.1st December 1995Way back at the start of April 1995, I was looking for a mindlessprogramming project. A friend of mine (Tim Hudson) said "why do not you do SSL, it has DES encryption in it and I would not mind using it In a SSL Telnet ".While It Was True I Had Written A des Library., Litledid I know,.
First of all, the SSL protocol contains DES encryption. Well and good. MyDES library was fast and portable. It also contained the RSA's RC4 streamcipher. Again, not a problem, some-one had just posted to sci.cryptsomething that was claimed to be RC4. It also contained IDEA, I had thespecifications, not a problem to implement. MD5, an RFC, trivial, at mostI could spend a week or so trying to see if I could speed up theimplementation. All in all a nice set of ciphers.Then the first 'expantion of the scope', RSA public keyencryption. Since I did not knowing a thing about public key encryptionor number theory, this appeared quite a daunting task. Just writing abig number library would be problomatic in itself, let alone making it fast.At this point the scope of 'implementing SSL' expands eponentialy.First of all, the RSA private keys were being kept in ASN.1 format.Thankfully the RSA PKCS series of documents explains this format. So I nowneeded to be Able to Encode and Decode Ar bitary ASN.1 objects. The Publickeys were embeded in X509 certificates. Hmm ... these are not onlyASN.1 objects but they make up a heirachy of authentication. Toauthenticate a X509 certificate one needs to retrieve it's issuerscertificate etc etc. Hmm .. ., so I also need to implement some kindof certificate management software. I would also have to implementsoftware to authenticate certificates. At this point the support code madethe SSL part of my library look quite small.Around this time, the first version of SSLeay was Released.
Ah, but here was the problem, I was not happy with the code so far. As mayhave become obvious, I had been treating all of this as a learningexersize, so I have completely written the library myself. As such, dueto the way it had grown like a fungus, much of the library was not'elagent 'or neat. There were global and static variables all over theplace, the SSL part did not even handle non-blocking IO.The Great rewrite began.As of this point in Time, The 'Great Rewrite' Has Almost Finished. so whatfollows is an approximate list of what is actually ssleay 0.5.0
/ ********* this needs to beddated for 0.6.0 ************* /
--- The library contains the following routines. Please note that most of thesefunctions are not specfic for SSL or any other particular cipherimplementation. I have tried to make all the routines as general purposeas possible. So you should not think of this library as an SSLimplemtation, but rather as a library of cryptographic functionsthat also contains SSL. I refer to each of these function groupings aslibraries since they are often capable of functioning as independantlibraries
First Up, The General Ciphers and Message Digests Supported by The Library.
MD2 rfc ???, a standard 'by parts' interface to this algorithm.MD5 rfc ???, the same type of interface as for the MD2 library except a different algorithm.SHA THe Secure Hash Algorithm. Again the same type of interface as MD2 / MD5 except the digest is 20 bytes.SHA1 The 'revised' version of SHA. Just about identical to SHA except for one tweak of an inner loop.DES This is my libdes library that has been floating around for the last few years . It has been enhanced for no other reason than completeness. It now supports ecb, cbc, cfb, ofb, cfb64, ofb64 in normal mode and triple DES modes of ecb, cbc, cfb64 and ofb64. cfb64 and ofb64 are functional interfaces to the 64 bit modes of cfb and ofb used in such a way thay they function as single character interfaces.RC4 The RSA Inc. stream cipher.RC2 The RSA Inc. block cipher.IDEA An implmentation of the IDEA cipher, the library supports ecb, cbc , Cfb64 and offb64 modes of operation.now all the Above exercise Ciphers and Digests Libraries Suppirl RtHIGHSPEED, Minimal 'Crap in The Way' Type Interfaces. for Fastest Andlowest Level Access, These Routines Should Be Used Directly.
Now There Was Also The Matter of public Key Crypto Systems. These isbased on large integer archmatic.
BN This is my large integer library. It supports all the normal arithmentic operations. It uses malloc extensivly and as such has no limits of the size of the numbers being manipulated. If you wish to use 4000 bit RSA moduli, these routines will handle it TO 'generate' prime number g 度 l p p 的 的 的 的 ◆ , it will just sit on top of the routines contained in this library.RSA This implements the RSA public key algorithm. It also contains routines that will generate a new private / public key pair. All the RSA functions conform to the PKCS # standard 1 .DH This is an implementation of the Diffie-Hellman protocol. There are all the require routines for the protocol, plus extra routines that can be used to generate a strong prime for use with a specified generator. While this last routine is not generally required By Applicatio ns implementing DH, It is present for completeness and because I thing it is much better to be able to 'generate' your own 'magic' numbers as oposed to using numbers suplied by others. I conform to the PKCS # 3 standard where required. You May Have Noticed The Preceeding Section Mentions The 'Generation' ofprime Numbers. Now this Requies the Use of 'Random Numbers'.
RAND This psuedo-random number library is based on MD5 at it's core and a large internal state (2k bytes). Once you have entered enough seed data into this random number algorithm I do not feel you will ever need to worry about it generating predictable output. Due to the way I am writing a portable library, I have left the issue of how to get good initial random seed data upto the application but I do have support routines for saving and loading a persistant random number state for use between program runs. Now to make all these ciphers easier to use, a higher levelinterface was required. In this form, the same function would be used toencrypt 'by parts', via any one of the above mentioned ciphers.EVP The Digital EnVeloPe library is quite large. At it's core are function to perform encryption and decryption by parts while using an initial parameter to specify which of the 17 different ciphers or 4 different message digests to use. On top of these are implmented the digital signatur E Functions, Sign, Verify, Seal and Open. Base64 Encoding of Binary Data IS Also Done in this library.
PEM rfc ???? describe the format for Privacy Enhanced eMail. As part of this standard, methods of encoding digital enveloped data is an ascii format are defined. As such, I use a form of these to encode enveloped data. While at this point in time full support for PEM has not been built into the library, a minimal subset of the secret key and Base64 encoding is present. These reoutines are mostly used to Ascii encode binary data with a 'type' associated with it and perhaps details of private key encryption used to encrypt the data. PKCS7 This is another Digital Envelope encoding standard which uses ASN.1 to encode the data. At this point in time, while there are some routines to encode and decode this binary format, full support is not present. As Mentioned, above, there are several different ways to encodedata structures.ASN1 This library is more a set of primatives used to encode the packing and unpacking of data structures. It is used by the X509 certificate standard and by the P KCS standards which are used by this library. It also contains routines for duplicating and signing the structures asocisated with X509. X509 The X509 library contains routines for packing and unpacking, verifying and just about every thing else you would want to do with X509 certificates.
PKCS7 PKCS7 is a standard for encoding digital envelope data structures. At this point in time the routines will load and save DER forms of these structees. They need to be re-worked to suport the BER form which is the normal way PKCS- 7 is encoded. If The preplery, this library is not ready, this library.
OBJ ASN.1 uses 'object identifiers' to identify objects. A set of functions were requred to translate from ASN.1 to an intenger, to a character string. This library provieds these translations Now I mentioned an X509 library. X509 specified a hieachy of certificateswhich needs to be traversed to authenticate particular certificates.METH This library is used to push 'methods' of retrieving certificates into the library. There are some supplied 'methods' with SSLeay but applications can add new methods if they so desire. This library HAS NOT BEEN FINISHED AND IS Not Being Used in this Version. Now All The Above Are Required for Use in The Initial Point of this Project.
SSL The SSL Protocol. This is a full. IT Support Both Server and Client Authentication. SSL V 3 Support Will Be Added WHEN The SSL V 3 Specification IS ReleaseD IN It's Final Form.
NOW QUITE A FEW of The Above Mentioned Libraries Rely on a Few 'Complex'Data Structures. For Each of these I have a library.
Lhash this is a has used extensifly.
Stack An Implemetation of a Stack Data Structure.
BUF A simple character array structure that also support a function to check that The application can specify the array is greater that a certain size, if it is not, it is realloced so that is it. TXT_DB A simple memory based text file data base. Unique Indexes That Will Be Enforced At Update Time.
CONF Most of the programs written for this library require a configuration file. Instead of letting programs constantly re-implment this subsystem, the CONF library provides a consistant and flexable interface to not only configuration files but also environment variables.
But what about when something goes wrong? The one advantage (and perhaps disadvantage) of all of thesefunctions being in one library was the ability to implement asingle error reporting system. ERR This library is used to report errors. The error system records library number, Function Number (In the Library) and Reason Number. Multiple Errors Can Be Reported So That An 'Error' TRACE IS CREATED. The Errors Can Be Printed In Numeric Or Textual Form. pre> body> html>