1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public License Version
5
* 1.1 (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
7
* http://www.mozilla.org/MPL/
9
* Software distributed under the License is distributed on an "AS IS" basis,
10
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
* for the specific language governing rights and limitations under the
14
* The Original Code is the Netscape security libraries.
16
* The Initial Developer of the Original Code is
17
* Netscape Communications Corporation.
18
* Portions created by the Initial Developer are Copyright (C) 1994-2000
19
* the Initial Developer. All Rights Reserved.
23
* Alternatively, the contents of this file may be used under the terms of
24
* either the GNU General Public License Version 2 or later (the "GPL"), or
25
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
* in which case the provisions of the GPL or the LGPL are applicable instead
27
* of those above. If you wish to allow use of your version of this file only
28
* under the terms of either the GPL or the LGPL, and not to allow others to
29
* use your version of this file under the terms of the MPL, indicate your
30
* decision by deleting the provisions above and replace them with the notice
31
* and other provisions required by the GPL or the LGPL. If you do not delete
32
* the provisions above, a recipient may use your version of this file under
33
* the terms of any one of the MPL, the GPL or the LGPL.
35
* ***** END LICENSE BLOCK ***** */
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
38
6
* Pretty-print some well-known BER or DER encoded data (e.g. certificates,
41
* $Id: pp.c,v 1.9 2007/09/25 03:46:23 nelson%bolyard.com Exp $
9
* $Id: pp.c,v 1.12 2012/08/16 06:57:24 kaie%kuix.de Exp $
44
12
#include "secutil.h"
62
30
"-t type", SEC_CT_PRIVATE_KEY);
63
31
fprintf(stderr, "%-20s %s, %s, %s,\n", "", SEC_CT_PUBLIC_KEY,
64
32
SEC_CT_CERTIFICATE, SEC_CT_CERTIFICATE_REQUEST);
65
fprintf(stderr, "%-20s %s or %s)\n", "", SEC_CT_PKCS7, SEC_CT_CRL);
33
fprintf(stderr, "%-20s %s, %s, %s or %s)\n", "", SEC_CT_CERTIFICATE_ID,
34
SEC_CT_PKCS7, SEC_CT_CRL, SEC_CT_NAME);
66
35
fprintf(stderr, "%-20s Input is in ascii encoded form (RFC1113)\n",
68
37
fprintf(stderr, "%-20s Define an input file to use (default is stdin)\n",
152
121
if (PORT_Strcmp(typeTag, SEC_CT_CERTIFICATE) == 0) {
153
122
rv = SECU_PrintSignedData(outFile, &data, "Certificate", 0,
154
123
SECU_PrintCertificate);
124
} else if (PORT_Strcmp(typeTag, SEC_CT_CERTIFICATE_ID) == 0) {
125
PRBool saveWrapeState = SECU_GetWrapEnabled();
126
SECU_EnableWrap(PR_FALSE);
127
rv = SECU_PrintSignedContent(outFile, &data, 0, 0,
128
SECU_PrintDumpDerIssuerAndSerial);
129
SECU_EnableWrap(saveWrapeState);
155
130
} else if (PORT_Strcmp(typeTag, SEC_CT_CERTIFICATE_REQUEST) == 0) {
156
131
rv = SECU_PrintSignedData(outFile, &data, "Certificate Request", 0,
157
132
SECU_PrintCertificateRequest);
166
141
} else if (PORT_Strcmp(typeTag, SEC_CT_PKCS7) == 0) {
167
142
rv = SECU_PrintPKCS7ContentInfo(outFile, &data,
168
143
"PKCS #7 Content Info", 0);
144
} else if (PORT_Strcmp(typeTag, SEC_CT_NAME) == 0) {
145
rv = SECU_PrintDERName(outFile, &data, "Name", 0);
170
147
fprintf(stderr, "%s: don't know how to print out '%s' files\n",
171
148
progName, typeTag);