Back to index

lightning-sunbird  0.9+nobinonly
des.h
Go to the documentation of this file.
00001 /*
00002  *  des.h
00003  *
00004  *  header file for DES-150 library
00005  *
00006  * ***** BEGIN LICENSE BLOCK *****
00007  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00008  *
00009  * The contents of this file are subject to the Mozilla Public License Version
00010  * 1.1 (the "License"); you may not use this file except in compliance with
00011  * the License. You may obtain a copy of the License at
00012  * http://www.mozilla.org/MPL/
00013  *
00014  * Software distributed under the License is distributed on an "AS IS" basis,
00015  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  * for the specific language governing rights and limitations under the
00017  * License.
00018  *
00019  * The Original Code is the DES-150 library.
00020  *
00021  * The Initial Developer of the Original Code is
00022  * Nelson B. Bolyard, nelsonb@iname.com.
00023  * Portions created by the Initial Developer are Copyright (C) 1990
00024  * the Initial Developer. All Rights Reserved.
00025  *
00026  * Contributor(s):
00027  *
00028  * Alternatively, the contents of this file may be used under the terms of
00029  * either the GNU General Public License Version 2 or later (the "GPL"), or
00030  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00031  * in which case the provisions of the GPL or the LGPL are applicable instead
00032  * of those above. If you wish to allow use of your version of this file only
00033  * under the terms of either the GPL or the LGPL, and not to allow others to
00034  * use your version of this file under the terms of the MPL, indicate your
00035  * decision by deleting the provisions above and replace them with the notice
00036  * and other provisions required by the GPL or the LGPL. If you do not delete
00037  * the provisions above, a recipient may use your version of this file under
00038  * the terms of any one of the MPL, the GPL or the LGPL.
00039  *
00040  * ***** END LICENSE BLOCK ***** */
00041 
00042 #ifndef _DES_H_
00043 #define _DES_H_ 1
00044 
00045 #include "blapi.h"
00046 
00047 typedef unsigned char BYTE;
00048 typedef unsigned int  HALF;
00049 
00050 #define HALFPTR(x) ((HALF *)(x))
00051 #define SHORTPTR(x) ((unsigned short *)(x))
00052 #define BYTEPTR(x) ((BYTE *)(x))
00053 
00054 typedef enum {
00055     DES_ENCRYPT = 0x5555,
00056     DES_DECRYPT = 0xAAAA
00057 } DESDirection;
00058 
00059 typedef void DESFunc(struct DESContextStr *cx, BYTE *out, const BYTE *in, 
00060                      unsigned int len);
00061 
00062 struct DESContextStr {
00063     /* key schedule, 16 internal keys, each with 8 6-bit parts */
00064     HALF ks0 [32];
00065     HALF ks1 [32];
00066     HALF ks2 [32];
00067     HALF iv  [2];
00068     DESDirection direction;
00069     DESFunc  *worker;
00070 };
00071 
00072 void DES_MakeSchedule( HALF * ks, const BYTE * key,   DESDirection direction);
00073 void DES_Do1Block(     HALF * ks, const BYTE * inbuf, BYTE * outbuf);
00074 
00075 #endif