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