Fix comments and indentation
This commit is contained in:
parent
0b93163551
commit
5d565bb378
51
keyutil.c
51
keyutil.c
|
@ -67,10 +67,13 @@
|
|||
/*
|
||||
* 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
|
||||
* code from NSS's security utilities and the certutil application.
|
||||
* Key generation, encryption, and certificate utility code based on
|
||||
* 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>
|
||||
*
|
||||
*/
|
||||
|
@ -268,7 +271,8 @@ static SECStatus loadCert(
|
|||
genericObjCert = PK11_CreateGenericObject(slot, theCertTemplate, 4, PR_FALSE /* isPerm */);
|
||||
if (!genericObjCert) {
|
||||
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));
|
||||
break;
|
||||
}
|
||||
|
@ -278,7 +282,8 @@ static SECStatus loadCert(
|
|||
*/
|
||||
cert = PK11_FindCertFromNickname((char *)nickname, NULL);
|
||||
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);
|
||||
rv = 255;
|
||||
break;
|
||||
|
@ -323,7 +328,6 @@ static SECStatus loadKey(
|
|||
SECKEYPrivateKey *privkey = NULL;
|
||||
|
||||
do {
|
||||
|
||||
attrs = theTemplate;
|
||||
PK11_SETATTRS(attrs, CKA_CLASS, &objClass, sizeof(objClass) ); 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);
|
||||
if (!privkey) {
|
||||
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));
|
||||
GEN_BREAK(SECFailure);
|
||||
}
|
||||
|
@ -384,7 +389,8 @@ static SECStatus loadKey(
|
|||
* @param keyfile the key file
|
||||
* @param pwdata access password
|
||||
*/
|
||||
static SECStatus loadCertAndKey(
|
||||
static SECStatus
|
||||
loadCertAndKey(
|
||||
PK11SlotInfo *slot,
|
||||
PRBool cacert,
|
||||
const char *certfile,
|
||||
|
@ -432,7 +438,6 @@ static SECStatus extractRSAKeysAndSubject(
|
|||
CERTCertificate *cert = NULL;
|
||||
|
||||
do {
|
||||
|
||||
cert = PK11_FindCertFromNickname((char *)nickname, NULL);
|
||||
if (!cert) {
|
||||
GEN_BREAK(SECFailure);
|
||||
|
@ -440,7 +445,8 @@ static SECStatus extractRSAKeysAndSubject(
|
|||
|
||||
*pubkey = CERT_ExtractPublicKey(cert);
|
||||
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()));
|
||||
GEN_BREAK(SECFailure);
|
||||
}
|
||||
|
@ -448,13 +454,14 @@ static SECStatus extractRSAKeysAndSubject(
|
|||
*privkey = PK11_FindKeyByDERCert(slot, cert, &pwdata);
|
||||
if (!*privkey) {
|
||||
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));
|
||||
*privkey= PK11_FindKeyByAnyCert(cert, &pwdata);
|
||||
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));
|
||||
|
||||
GEN_BREAK(SECFailure);
|
||||
}
|
||||
|
||||
|
@ -462,7 +469,8 @@ static SECStatus extractRSAKeysAndSubject(
|
|||
*subject = CERT_AsciiToName(cert->subjectName);
|
||||
|
||||
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);
|
||||
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 *
|
||||
GetCertRequest(PRFileDesc *inFile, PRBool ascii)
|
||||
{
|
||||
|
@ -537,9 +547,6 @@ GetCertRequest(PRFileDesc *inFile, PRBool ascii)
|
|||
return certReq;
|
||||
}
|
||||
|
||||
/*
|
||||
* Modeled after the one in certutil
|
||||
*/
|
||||
static SECStatus
|
||||
CertReq(SECKEYPrivateKey *privk, SECKEYPublicKey *pubk, KeyType keyType,
|
||||
SECOidTag hashAlgTag, CERTName *subject, char *phone, int ascii,
|
||||
|
@ -664,9 +671,6 @@ CertReq(SECKEYPrivateKey *privk, SECKEYPublicKey *pubk, KeyType keyType,
|
|||
return SECSuccess;
|
||||
}
|
||||
|
||||
/*
|
||||
* Modeled after the one in certutil
|
||||
*/
|
||||
static CERTCertificate *
|
||||
MakeV1Cert(CERTCertDBHandle * handle,
|
||||
CERTCertificateRequest *req,
|
||||
|
@ -718,9 +722,6 @@ MakeV1Cert(CERTCertDBHandle * handle,
|
|||
return(cert);
|
||||
}
|
||||
|
||||
/*
|
||||
* Modelled after the one in certutil
|
||||
*/
|
||||
static SECItem *
|
||||
SignCert(CERTCertDBHandle *handle, CERTCertificate *cert, PRBool selfsign,
|
||||
SECOidTag hashAlgTag,
|
||||
|
@ -1616,7 +1617,7 @@ shutdown:
|
|||
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
|
||||
* code from NSS's security utilities and the certutil application.
|
||||
|
|
Loading…
Reference in New Issue