Fix comments and indentation

This commit is contained in:
Elio Maldonado 2008-10-20 20:45:04 +00:00
parent 0b93163551
commit 5d565bb378

View File

@ -67,10 +67,13 @@
/* /*
* keyutil.c * keyutil.c
* *
* Utility for managing certificates and the cert database * Command line utility for generating certificates and certificate signing requests.
* It is invoked by crypto-utils' genkey when used in OpenSSL compatibility mode.
* *
* Key generation, encryption, and certificate utility code, based on * Key generation, encryption, and certificate utility code based on
* code from NSS's security utilities and the certutil application. * on code from NSS's security utilities and the certutil application.
* Pem file key and certificate loading code based on code from the
* NSS-enabled libcurl.
* Elio Maldonado <emaldona@redhat.com> * Elio Maldonado <emaldona@redhat.com>
* *
*/ */
@ -268,7 +271,8 @@ static SECStatus loadCert(
genericObjCert = PK11_CreateGenericObject(slot, theCertTemplate, 4, PR_FALSE /* isPerm */); genericObjCert = PK11_CreateGenericObject(slot, theCertTemplate, 4, PR_FALSE /* isPerm */);
if (!genericObjCert) { if (!genericObjCert) {
rv = PR_GetError(); rv = PR_GetError();
PR_fprintf(PR_STDERR, "%s: unable to Create object for cert, (%s)\n", PR_fprintf(PR_STDERR,
"%s: unable to Create object for cert, (%s)\n",
progName, SECU_Strerror(rv)); progName, SECU_Strerror(rv));
break; break;
} }
@ -278,7 +282,8 @@ static SECStatus loadCert(
*/ */
cert = PK11_FindCertFromNickname((char *)nickname, NULL); cert = PK11_FindCertFromNickname((char *)nickname, NULL);
if (!cert) { if (!cert) {
PR_fprintf(PR_STDERR, "%s: Can't find cert named (%s), bailing out\n", PR_fprintf(PR_STDERR,
"%s: Can't find cert named (%s), bailing out\n",
progName, nickname); progName, nickname);
rv = 255; rv = 255;
break; break;
@ -323,7 +328,6 @@ static SECStatus loadKey(
SECKEYPrivateKey *privkey = NULL; SECKEYPrivateKey *privkey = NULL;
do { do {
attrs = theTemplate; attrs = theTemplate;
PK11_SETATTRS(attrs, CKA_CLASS, &objClass, sizeof(objClass) ); attrs++; PK11_SETATTRS(attrs, CKA_CLASS, &objClass, sizeof(objClass) ); attrs++;
PK11_SETATTRS(attrs, CKA_TOKEN, &cktrue, sizeof(CK_BBOOL) ); attrs++; PK11_SETATTRS(attrs, CKA_TOKEN, &cktrue, sizeof(CK_BBOOL) ); attrs++;
@ -360,7 +364,8 @@ static SECStatus loadKey(
privkey = PK11_FindPrivateKeyFromCert(slot, cert, pwdata->data); privkey = PK11_FindPrivateKeyFromCert(slot, cert, pwdata->data);
if (!privkey) { if (!privkey) {
rv = PR_GetError(); rv = PR_GetError();
PR_fprintf(PR_STDERR, "%s: unable to find the key for cert, (%s)\n", PR_fprintf(PR_STDERR,
"%s: unable to find the key for cert, (%s)\n",
progName, SECU_Strerror(rv)); progName, SECU_Strerror(rv));
GEN_BREAK(SECFailure); GEN_BREAK(SECFailure);
} }
@ -384,7 +389,8 @@ static SECStatus loadKey(
* @param keyfile the key file * @param keyfile the key file
* @param pwdata access password * @param pwdata access password
*/ */
static SECStatus loadCertAndKey( static SECStatus
loadCertAndKey(
PK11SlotInfo *slot, PK11SlotInfo *slot,
PRBool cacert, PRBool cacert,
const char *certfile, const char *certfile,
@ -432,7 +438,6 @@ static SECStatus extractRSAKeysAndSubject(
CERTCertificate *cert = NULL; CERTCertificate *cert = NULL;
do { do {
cert = PK11_FindCertFromNickname((char *)nickname, NULL); cert = PK11_FindCertFromNickname((char *)nickname, NULL);
if (!cert) { if (!cert) {
GEN_BREAK(SECFailure); GEN_BREAK(SECFailure);
@ -440,7 +445,8 @@ static SECStatus extractRSAKeysAndSubject(
*pubkey = CERT_ExtractPublicKey(cert); *pubkey = CERT_ExtractPublicKey(cert);
if (!*pubkey) { if (!*pubkey) {
PR_fprintf(PR_STDERR, "%s: Could not get public key from cert, (%s)\n", PR_fprintf(PR_STDERR,
"%s: Could not get public key from cert, (%s)\n",
progName, SECU_Strerror(PR_GetError())); progName, SECU_Strerror(PR_GetError()));
GEN_BREAK(SECFailure); GEN_BREAK(SECFailure);
} }
@ -448,13 +454,14 @@ static SECStatus extractRSAKeysAndSubject(
*privkey = PK11_FindKeyByDERCert(slot, cert, &pwdata); *privkey = PK11_FindKeyByDERCert(slot, cert, &pwdata);
if (!*privkey) { if (!*privkey) {
rv = PR_GetError(); rv = PR_GetError();
PR_fprintf(PR_STDERR, "%s: unable to find the key with PK11_FindKeyByDERCert, (%s)\n", PR_fprintf(PR_STDERR,
"%s: unable to find the key with PK11_FindKeyByDERCert, (%s)\n",
progName, SECU_Strerror(rv)); progName, SECU_Strerror(rv));
*privkey= PK11_FindKeyByAnyCert(cert, &pwdata); *privkey= PK11_FindKeyByAnyCert(cert, &pwdata);
rv = PR_GetError(); rv = PR_GetError();
PR_fprintf(PR_STDERR, "%s: unable to find the key with PK11_FindKeyByAnyCert, (%s)\n", PR_fprintf(PR_STDERR,
"%s: unable to find the key with PK11_FindKeyByAnyCert, (%s)\n",
progName, SECU_Strerror(rv)); progName, SECU_Strerror(rv));
GEN_BREAK(SECFailure); GEN_BREAK(SECFailure);
} }
@ -462,7 +469,8 @@ static SECStatus extractRSAKeysAndSubject(
*subject = CERT_AsciiToName(cert->subjectName); *subject = CERT_AsciiToName(cert->subjectName);
if (!*subject) { if (!*subject) {
PR_fprintf(PR_STDERR, "%s -s: improperly formatted name: \"%s\"\n", PR_fprintf(PR_STDERR,
"%s -s: improperly formatted name: \"%s\"\n",
progName, cert->subjectName); progName, cert->subjectName);
GEN_BREAK(SECFailure); GEN_BREAK(SECFailure);
} }
@ -475,8 +483,10 @@ static SECStatus extractRSAKeysAndSubject(
} }
/* /*
* Modeled after the one in certutil * GetCertRequest, CertReq, MakeV1Cert, SignCert, and CreateCert
* are modeled after the corresponding ones in certutil.
*/ */
static CERTCertificateRequest * static CERTCertificateRequest *
GetCertRequest(PRFileDesc *inFile, PRBool ascii) GetCertRequest(PRFileDesc *inFile, PRBool ascii)
{ {
@ -537,9 +547,6 @@ GetCertRequest(PRFileDesc *inFile, PRBool ascii)
return certReq; return certReq;
} }
/*
* Modeled after the one in certutil
*/
static SECStatus static SECStatus
CertReq(SECKEYPrivateKey *privk, SECKEYPublicKey *pubk, KeyType keyType, CertReq(SECKEYPrivateKey *privk, SECKEYPublicKey *pubk, KeyType keyType,
SECOidTag hashAlgTag, CERTName *subject, char *phone, int ascii, SECOidTag hashAlgTag, CERTName *subject, char *phone, int ascii,
@ -664,9 +671,6 @@ CertReq(SECKEYPrivateKey *privk, SECKEYPublicKey *pubk, KeyType keyType,
return SECSuccess; return SECSuccess;
} }
/*
* Modeled after the one in certutil
*/
static CERTCertificate * static CERTCertificate *
MakeV1Cert(CERTCertDBHandle * handle, MakeV1Cert(CERTCertDBHandle * handle,
CERTCertificateRequest *req, CERTCertificateRequest *req,
@ -718,9 +722,6 @@ MakeV1Cert(CERTCertDBHandle * handle,
return(cert); return(cert);
} }
/*
* Modelled after the one in certutil
*/
static SECItem * static SECItem *
SignCert(CERTCertDBHandle *handle, CERTCertificate *cert, PRBool selfsign, SignCert(CERTCertDBHandle *handle, CERTCertificate *cert, PRBool selfsign,
SECOidTag hashAlgTag, SECOidTag hashAlgTag,
@ -1616,7 +1617,7 @@ shutdown:
return rv == SECSuccess ? 0 : 255; return rv == SECSuccess ? 0 : 255;
} }
/* $Id: keyutil.c,v 1.7 2008/10/19 05:08:53 emaldonado Exp $ */ /* $Id: keyutil.c,v 1.8 2008/10/19 17:50:08 emaldonado Exp $ */
/* Key generation, encryption, and certificate utility code, based on /* Key generation, encryption, and certificate utility code, based on
* code from NSS's security utilities and the certutil application. * code from NSS's security utilities and the certutil application.