PageRenderTime 30ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/gecko_api/include/preenc.h

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