Home | History | Annotate | Download | only in ssl
      1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
      2 
      3 /*
      4  * Fortezza support is removed.
      5  *
      6  * This Source Code Form is subject to the terms of the Mozilla Public
      7  * License, v. 2.0. If a copy of the MPL was not distributed with this
      8  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      9 
     10 /* Fortezza support is removed.
     11  * This file remains so that old programs will continue to compile,
     12  * But this functionality is no longer supported or implemented.
     13  */
     14 
     15 #include "seccomon.h"
     16 #include "prio.h"
     17 
     18 typedef struct PEHeaderStr PEHeader;
     19 
     20 #define PE_MIME_TYPE "application/pre-encrypted"
     21 
     22 typedef struct PEFortezzaHeaderStr PEFortezzaHeader;
     23 typedef struct PEFortezzaGeneratedHeaderStr PEFortezzaGeneratedHeader;
     24 typedef struct PEFixedKeyHeaderStr PEFixedKeyHeader;
     25 typedef struct PERSAKeyHeaderStr PERSAKeyHeader;
     26 
     27 struct PEFortezzaHeaderStr {
     28     unsigned char key[12];
     29     unsigned char iv[24];
     30     unsigned char hash[20];
     31     unsigned char serial[8];
     32 };
     33 
     34 struct PEFortezzaGeneratedHeaderStr {
     35     unsigned char key[12];
     36     unsigned char iv[24];
     37     unsigned char hash[20];
     38     unsigned char Ra[128];
     39     unsigned char Y[128];
     40 };
     41 
     42 struct PEFixedKeyHeaderStr {
     43     unsigned char pkcs11Mech[4];
     44     unsigned char labelLen[2];
     45     unsigned char keyIDLen[2];
     46     unsigned char ivLen[2];
     47     unsigned char keyLen[2];
     48     unsigned char data[1];
     49 };
     50 
     51 struct PERSAKeyHeaderStr {
     52     unsigned char pkcs11Mech[4];
     53     unsigned char issuerLen[2];
     54     unsigned char serialLen[2];
     55     unsigned char ivLen[2];
     56     unsigned char keyLen[2];
     57     unsigned char data[1];
     58 };
     59 
     60 #define PEFIXED_Label(header) (header->data)
     61 #define PEFIXED_KeyID(header) (&header->data[GetInt2(header->labelLen)])
     62 #define PEFIXED_IV(header) (&header->data[GetInt2(header->labelLen)\
     63 						+GetInt2(header->keyIDLen)])
     64 #define PEFIXED_Key(header) (&header->data[GetInt2(header->labelLen)\
     65 			+GetInt2(header->keyIDLen)+GetInt2(header->keyLen)])
     66 #define PERSA_Issuer(header) (header->data)
     67 #define PERSA_Serial(header) (&header->data[GetInt2(header->issuerLen)])
     68 #define PERSA_IV(header) (&header->data[GetInt2(header->issuerLen)\
     69 						+GetInt2(header->serialLen)])
     70 #define PERSA_Key(header) (&header->data[GetInt2(header->issuerLen)\
     71 			+GetInt2(header->serialLen)+GetInt2(header->keyLen)])
     72 struct PEHeaderStr {
     73     unsigned char magic  [2];
     74     unsigned char len    [2];
     75     unsigned char type   [2];
     76     unsigned char version[2];
     77     union {
     78         PEFortezzaHeader          fortezza;
     79         PEFortezzaGeneratedHeader g_fortezza;
     80 	PEFixedKeyHeader          fixed;
     81 	PERSAKeyHeader            rsa;
     82     } u;
     83 };
     84 
     85 #define PE_CRYPT_INTRO_LEN 8
     86 #define PE_INTRO_LEN 4
     87 #define PE_BASE_HEADER_LEN  8
     88 
     89 #define PRE_BLOCK_SIZE 8
     90 
     91 
     92 #define GetInt2(c) ((c[0] << 8) | c[1])
     93 #define GetInt4(c) (((unsigned long)c[0] << 24)|((unsigned long)c[1] << 16)\
     94 			|((unsigned long)c[2] << 8)| ((unsigned long)c[3]))
     95 #define PutInt2(c,i) ((c[1] = (i) & 0xff), (c[0] = ((i) >> 8) & 0xff))
     96 #define PutInt4(c,i) ((c[0]=((i) >> 24) & 0xff),(c[1]=((i) >> 16) & 0xff),\
     97 			(c[2] = ((i) >> 8) & 0xff), (c[3] = (i) & 0xff))
     98 
     99 #define PRE_MAGIC		0xc0de
    100 #define PRE_VERSION		0x1010
    101 #define PRE_FORTEZZA_FILE	0x00ff
    102 #define PRE_FORTEZZA_STREAM	0x00f5
    103 #define PRE_FORTEZZA_GEN_STREAM	0x00f6
    104 #define PRE_FIXED_FILE		0x000f
    105 #define PRE_RSA_FILE		0x001f
    106 #define PRE_FIXED_STREAM	0x0005
    107 
    108 PEHeader *SSL_PreencryptedStreamToFile(PRFileDesc *fd, PEHeader *,
    109 				       int *headerSize);
    110 
    111 PEHeader *SSL_PreencryptedFileToStream(PRFileDesc *fd, PEHeader *,
    112 				       int *headerSize);
    113 
    114