Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | /* |
michael@0 | 6 | * seccomon.h - common data structures for security libraries |
michael@0 | 7 | * |
michael@0 | 8 | * This file should have lowest-common-denominator datastructures |
michael@0 | 9 | * for security libraries. It should not be dependent on any other |
michael@0 | 10 | * headers, and should not require linking with any libraries. |
michael@0 | 11 | */ |
michael@0 | 12 | |
michael@0 | 13 | #ifndef _SECCOMMON_H_ |
michael@0 | 14 | #define _SECCOMMON_H_ |
michael@0 | 15 | |
michael@0 | 16 | #include "utilrename.h" |
michael@0 | 17 | #include "prtypes.h" |
michael@0 | 18 | |
michael@0 | 19 | |
michael@0 | 20 | #ifdef __cplusplus |
michael@0 | 21 | # define SEC_BEGIN_PROTOS extern "C" { |
michael@0 | 22 | # define SEC_END_PROTOS } |
michael@0 | 23 | #else |
michael@0 | 24 | # define SEC_BEGIN_PROTOS |
michael@0 | 25 | # define SEC_END_PROTOS |
michael@0 | 26 | #endif |
michael@0 | 27 | |
michael@0 | 28 | #include "secport.h" |
michael@0 | 29 | |
michael@0 | 30 | typedef enum { |
michael@0 | 31 | siBuffer = 0, |
michael@0 | 32 | siClearDataBuffer = 1, |
michael@0 | 33 | siCipherDataBuffer = 2, |
michael@0 | 34 | siDERCertBuffer = 3, |
michael@0 | 35 | siEncodedCertBuffer = 4, |
michael@0 | 36 | siDERNameBuffer = 5, |
michael@0 | 37 | siEncodedNameBuffer = 6, |
michael@0 | 38 | siAsciiNameString = 7, |
michael@0 | 39 | siAsciiString = 8, |
michael@0 | 40 | siDEROID = 9, |
michael@0 | 41 | siUnsignedInteger = 10, |
michael@0 | 42 | siUTCTime = 11, |
michael@0 | 43 | siGeneralizedTime = 12, |
michael@0 | 44 | siVisibleString = 13, |
michael@0 | 45 | siUTF8String = 14, |
michael@0 | 46 | siBMPString = 15 |
michael@0 | 47 | } SECItemType; |
michael@0 | 48 | |
michael@0 | 49 | typedef struct SECItemStr SECItem; |
michael@0 | 50 | |
michael@0 | 51 | struct SECItemStr { |
michael@0 | 52 | SECItemType type; |
michael@0 | 53 | unsigned char *data; |
michael@0 | 54 | unsigned int len; |
michael@0 | 55 | }; |
michael@0 | 56 | |
michael@0 | 57 | typedef struct SECItemArrayStr SECItemArray; |
michael@0 | 58 | |
michael@0 | 59 | struct SECItemArrayStr { |
michael@0 | 60 | SECItem *items; |
michael@0 | 61 | unsigned int len; |
michael@0 | 62 | }; |
michael@0 | 63 | |
michael@0 | 64 | /* |
michael@0 | 65 | ** A status code. Status's are used by procedures that return status |
michael@0 | 66 | ** values. Again the motivation is so that a compiler can generate |
michael@0 | 67 | ** warnings when return values are wrong. Correct testing of status codes: |
michael@0 | 68 | ** |
michael@0 | 69 | ** SECStatus rv; |
michael@0 | 70 | ** rv = some_function (some_argument); |
michael@0 | 71 | ** if (rv != SECSuccess) |
michael@0 | 72 | ** do_an_error_thing(); |
michael@0 | 73 | ** |
michael@0 | 74 | */ |
michael@0 | 75 | typedef enum _SECStatus { |
michael@0 | 76 | SECWouldBlock = -2, |
michael@0 | 77 | SECFailure = -1, |
michael@0 | 78 | SECSuccess = 0 |
michael@0 | 79 | } SECStatus; |
michael@0 | 80 | |
michael@0 | 81 | /* |
michael@0 | 82 | ** A comparison code. Used for procedures that return comparision |
michael@0 | 83 | ** values. Again the motivation is so that a compiler can generate |
michael@0 | 84 | ** warnings when return values are wrong. |
michael@0 | 85 | */ |
michael@0 | 86 | typedef enum _SECComparison { |
michael@0 | 87 | SECLessThan = -1, |
michael@0 | 88 | SECEqual = 0, |
michael@0 | 89 | SECGreaterThan = 1 |
michael@0 | 90 | } SECComparison; |
michael@0 | 91 | |
michael@0 | 92 | #endif /* _SECCOMMON_H_ */ |