OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ |
| 2 |
| 3 /* |
| 4 * Fortezza support is removed. |
| 5 * |
| 6 * ***** BEGIN LICENSE BLOCK ***** |
| 7 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 8 * |
| 9 * The contents of this file are subject to the Mozilla Public License Version |
| 10 * 1.1 (the "License"); you may not use this file except in compliance with |
| 11 * the License. You may obtain a copy of the License at |
| 12 * http://www.mozilla.org/MPL/ |
| 13 * |
| 14 * Software distributed under the License is distributed on an "AS IS" basis, |
| 15 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 16 * for the specific language governing rights and limitations under the |
| 17 * License. |
| 18 * |
| 19 * The Original Code is the Netscape security libraries. |
| 20 * |
| 21 * The Initial Developer of the Original Code is |
| 22 * Netscape Communications Corporation. |
| 23 * Portions created by the Initial Developer are Copyright (C) 1994-2000 |
| 24 * the Initial Developer. All Rights Reserved. |
| 25 * |
| 26 * Contributor(s): |
| 27 * |
| 28 * Alternatively, the contents of this file may be used under the terms of |
| 29 * either the GNU General Public License Version 2 or later (the "GPL"), or |
| 30 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
| 31 * in which case the provisions of the GPL or the LGPL are applicable instead |
| 32 * of those above. If you wish to allow use of your version of this file only |
| 33 * under the terms of either the GPL or the LGPL, and not to allow others to |
| 34 * use your version of this file under the terms of the MPL, indicate your |
| 35 * decision by deleting the provisions above and replace them with the notice |
| 36 * and other provisions required by the GPL or the LGPL. If you do not delete |
| 37 * the provisions above, a recipient may use your version of this file under |
| 38 * the terms of any one of the MPL, the GPL or the LGPL. |
| 39 * |
| 40 * ***** END LICENSE BLOCK ***** */ |
| 41 /* $Id: preenc.h,v 1.6 2005/08/16 03:42:26 nelsonb%netscape.com Exp $ */ |
| 42 |
| 43 /* Fortezza support is removed. |
| 44 * This file remains so that old programs will continue to compile, |
| 45 * But this functionality is no longer supported or implemented. |
| 46 */ |
| 47 |
| 48 #include "seccomon.h" |
| 49 #include "prio.h" |
| 50 |
| 51 typedef struct PEHeaderStr PEHeader; |
| 52 |
| 53 #define PE_MIME_TYPE "application/pre-encrypted" |
| 54 |
| 55 typedef struct PEFortezzaHeaderStr PEFortezzaHeader; |
| 56 typedef struct PEFortezzaGeneratedHeaderStr PEFortezzaGeneratedHeader; |
| 57 typedef struct PEFixedKeyHeaderStr PEFixedKeyHeader; |
| 58 typedef struct PERSAKeyHeaderStr PERSAKeyHeader; |
| 59 |
| 60 struct PEFortezzaHeaderStr { |
| 61 unsigned char key[12]; |
| 62 unsigned char iv[24]; |
| 63 unsigned char hash[20]; |
| 64 unsigned char serial[8]; |
| 65 }; |
| 66 |
| 67 struct PEFortezzaGeneratedHeaderStr { |
| 68 unsigned char key[12]; |
| 69 unsigned char iv[24]; |
| 70 unsigned char hash[20]; |
| 71 unsigned char Ra[128]; |
| 72 unsigned char Y[128]; |
| 73 }; |
| 74 |
| 75 struct PEFixedKeyHeaderStr { |
| 76 unsigned char pkcs11Mech[4]; |
| 77 unsigned char labelLen[2]; |
| 78 unsigned char keyIDLen[2]; |
| 79 unsigned char ivLen[2]; |
| 80 unsigned char keyLen[2]; |
| 81 unsigned char data[1]; |
| 82 }; |
| 83 |
| 84 struct PERSAKeyHeaderStr { |
| 85 unsigned char pkcs11Mech[4]; |
| 86 unsigned char issuerLen[2]; |
| 87 unsigned char serialLen[2]; |
| 88 unsigned char ivLen[2]; |
| 89 unsigned char keyLen[2]; |
| 90 unsigned char data[1]; |
| 91 }; |
| 92 |
| 93 #define PEFIXED_Label(header) (header->data) |
| 94 #define PEFIXED_KeyID(header) (&header->data[GetInt2(header->labelLen)]) |
| 95 #define PEFIXED_IV(header) (&header->data[GetInt2(header->labelLen)\ |
| 96 +GetInt2(header->keyIDLen)]) |
| 97 #define PEFIXED_Key(header) (&header->data[GetInt2(header->labelLen)\ |
| 98 +GetInt2(header->keyIDLen)+GetInt2(header->keyLen)]) |
| 99 #define PERSA_Issuer(header) (header->data) |
| 100 #define PERSA_Serial(header) (&header->data[GetInt2(header->issuerLen)]) |
| 101 #define PERSA_IV(header) (&header->data[GetInt2(header->issuerLen)\ |
| 102 +GetInt2(header->serialLen)]) |
| 103 #define PERSA_Key(header) (&header->data[GetInt2(header->issuerLen)\ |
| 104 +GetInt2(header->serialLen)+GetInt2(header->keyLen)]) |
| 105 struct PEHeaderStr { |
| 106 unsigned char magic [2]; |
| 107 unsigned char len [2]; |
| 108 unsigned char type [2]; |
| 109 unsigned char version[2]; |
| 110 union { |
| 111 PEFortezzaHeader fortezza; |
| 112 PEFortezzaGeneratedHeader g_fortezza; |
| 113 PEFixedKeyHeader fixed; |
| 114 PERSAKeyHeader rsa; |
| 115 } u; |
| 116 }; |
| 117 |
| 118 #define PE_CRYPT_INTRO_LEN 8 |
| 119 #define PE_INTRO_LEN 4 |
| 120 #define PE_BASE_HEADER_LEN 8 |
| 121 |
| 122 #define PRE_BLOCK_SIZE 8 |
| 123 |
| 124 |
| 125 #define GetInt2(c) ((c[0] << 8) | c[1]) |
| 126 #define GetInt4(c) (((unsigned long)c[0] << 24)|((unsigned long)c[1] << 16)\ |
| 127 |((unsigned long)c[2] << 8)| ((unsigned long)c[3])) |
| 128 #define PutInt2(c,i) ((c[1] = (i) & 0xff), (c[0] = ((i) >> 8) & 0xff)) |
| 129 #define PutInt4(c,i) ((c[0]=((i) >> 24) & 0xff),(c[1]=((i) >> 16) & 0xff),\ |
| 130 (c[2] = ((i) >> 8) & 0xff), (c[3] = (i) & 0xff)) |
| 131 |
| 132 #define PRE_MAGIC 0xc0de |
| 133 #define PRE_VERSION 0x1010 |
| 134 #define PRE_FORTEZZA_FILE 0x00ff |
| 135 #define PRE_FORTEZZA_STREAM 0x00f5 |
| 136 #define PRE_FORTEZZA_GEN_STREAM 0x00f6 |
| 137 #define PRE_FIXED_FILE 0x000f |
| 138 #define PRE_RSA_FILE 0x001f |
| 139 #define PRE_FIXED_STREAM 0x0005 |
| 140 |
| 141 PEHeader *SSL_PreencryptedStreamToFile(PRFileDesc *fd, PEHeader *, |
| 142 int *headerSize); |
| 143 |
| 144 PEHeader *SSL_PreencryptedFileToStream(PRFileDesc *fd, PEHeader *, |
| 145 int *headerSize); |
| 146 |
OLD | NEW |