mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-25 18:07:31 +09:00
Replace NSS with Pale Moon's
This commit is contained in:
parent
ff1e5e48bf
commit
8c2e376f94
2870 changed files with 1762232 additions and 1374220 deletions
|
|
@ -5,6 +5,8 @@
|
|||
* This file contains functions to manage asymetric keys, (public and
|
||||
* private keys).
|
||||
*/
|
||||
#include <stddef.h>
|
||||
|
||||
#include "seccomon.h"
|
||||
#include "secmod.h"
|
||||
#include "secmodi.h"
|
||||
|
|
@ -230,7 +232,7 @@ PK11_ImportPublicKey(PK11SlotInfo *slot, SECKEYPublicKey *pubKey,
|
|||
pk11_SignedToUnsigned(attrs);
|
||||
}
|
||||
}
|
||||
rv = PK11_CreateNewObject(slot, CK_INVALID_SESSION, theTemplate,
|
||||
rv = PK11_CreateNewObject(slot, CK_INVALID_HANDLE, theTemplate,
|
||||
templateCount, isToken, &objectID);
|
||||
if (ckaId) {
|
||||
SECITEM_FreeItem(ckaId, PR_TRUE);
|
||||
|
|
@ -1085,7 +1087,7 @@ pk11_loadPrivKeyWithFlags(PK11SlotInfo *slot, SECKEYPrivateKey *privKey,
|
|||
}
|
||||
|
||||
/* now Store the puppies */
|
||||
rv = PK11_CreateNewObject(slot, CK_INVALID_SESSION, privTemplate,
|
||||
rv = PK11_CreateNewObject(slot, CK_INVALID_HANDLE, privTemplate,
|
||||
count, token, &objectID);
|
||||
PORT_FreeArena(arena, PR_TRUE);
|
||||
if (rv != SECSuccess) {
|
||||
|
|
@ -1520,13 +1522,13 @@ PK11_GenerateKeyPairWithOpFlags(PK11SlotInfo *slot, CK_MECHANISM_TYPE type,
|
|||
restore = PR_TRUE;
|
||||
} else {
|
||||
session_handle = slot->session;
|
||||
if (session_handle != CK_INVALID_SESSION)
|
||||
if (session_handle != CK_INVALID_HANDLE)
|
||||
PK11_EnterSlotMonitor(slot);
|
||||
restore = PR_FALSE;
|
||||
haslock = PR_TRUE;
|
||||
}
|
||||
|
||||
if (session_handle == CK_INVALID_SESSION) {
|
||||
if (session_handle == CK_INVALID_HANDLE) {
|
||||
PORT_SetError(SEC_ERROR_BAD_DATA);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1901,12 +1903,12 @@ try_faulty_3des:
|
|||
}
|
||||
|
||||
/* if we are unable to import the key and the pbeMechType is
|
||||
* CKM_NETSCAPE_PBE_SHA1_TRIPLE_DES_CBC, then it is possible that
|
||||
* CKM_NSS_PBE_SHA1_TRIPLE_DES_CBC, then it is possible that
|
||||
* the encrypted blob was created with a buggy key generation method
|
||||
* which is described in the PKCS 12 implementation notes. So we
|
||||
* need to try importing via that method.
|
||||
*/
|
||||
if ((pbeMechType == CKM_NETSCAPE_PBE_SHA1_TRIPLE_DES_CBC) && (!faulty3DES)) {
|
||||
if ((pbeMechType == CKM_NSS_PBE_SHA1_TRIPLE_DES_CBC) && (!faulty3DES)) {
|
||||
/* clean up after ourselves before redoing the key generation. */
|
||||
|
||||
PK11_FreeSymKey(key);
|
||||
|
|
@ -1967,14 +1969,20 @@ PK11_ExportPrivateKeyInfo(CERTCertificate *cert, void *wincx)
|
|||
return pki;
|
||||
}
|
||||
|
||||
/* V2 refers to PKCS #5 V2 here. If a PKCS #5 v1 or PKCS #12 pbe is passed
|
||||
* for pbeTag, then encTag and hashTag are ignored. If pbe is an encryption
|
||||
* algorithm, then PKCS #5 V2 is used with prfTag for the prf. If prfTag isn't
|
||||
* supplied prf will be SEC_OID_HMAC_SHA1 */
|
||||
SECKEYEncryptedPrivateKeyInfo *
|
||||
PK11_ExportEncryptedPrivKeyInfo(
|
||||
PK11_ExportEncryptedPrivKeyInfoV2(
|
||||
PK11SlotInfo *slot, /* optional, encrypt key in this slot */
|
||||
SECOidTag algTag, /* encrypt key with this algorithm */
|
||||
SECOidTag pbeAlg, /* PBE algorithm to encrypt the with key */
|
||||
SECOidTag encAlg, /* Encryption algorithm to Encrypt the key with */
|
||||
SECOidTag prfAlg, /* Hash algorithm for PRF */
|
||||
SECItem *pwitem, /* password for PBE encryption */
|
||||
SECKEYPrivateKey *pk, /* encrypt this private key */
|
||||
int iteration, /* interations for PBE alg */
|
||||
void *wincx) /* context for password callback ? */
|
||||
void *pwArg) /* context for password callback */
|
||||
{
|
||||
SECKEYEncryptedPrivateKeyInfo *epki = NULL;
|
||||
PLArenaPool *arena = NULL;
|
||||
|
|
@ -1995,7 +2003,7 @@ PK11_ExportEncryptedPrivKeyInfo(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
algid = sec_pkcs5CreateAlgorithmID(algTag, SEC_OID_UNKNOWN, SEC_OID_UNKNOWN,
|
||||
algid = sec_pkcs5CreateAlgorithmID(pbeAlg, encAlg, prfAlg,
|
||||
&pbeAlgTag, 0, NULL, iteration);
|
||||
if (algid == NULL) {
|
||||
return NULL;
|
||||
|
|
@ -2024,7 +2032,7 @@ PK11_ExportEncryptedPrivKeyInfo(
|
|||
slot = pk->pkcs11Slot;
|
||||
}
|
||||
}
|
||||
key = PK11_PBEKeyGen(slot, algid, pwitem, PR_FALSE, wincx);
|
||||
key = PK11_PBEKeyGen(slot, algid, pwitem, PR_FALSE, pwArg);
|
||||
if (key == NULL) {
|
||||
rv = SECFailure;
|
||||
goto loser;
|
||||
|
|
@ -2118,6 +2126,46 @@ loser:
|
|||
return epki;
|
||||
}
|
||||
|
||||
SECKEYEncryptedPrivateKeyInfo *
|
||||
PK11_ExportEncryptedPrivKeyInfo(
|
||||
PK11SlotInfo *slot, /* optional, encrypt key in this slot */
|
||||
SECOidTag algTag, /* PBE algorithm to encrypt the with key */
|
||||
SECItem *pwitem, /* password for PBE encryption */
|
||||
SECKEYPrivateKey *pk, /* encrypt this private key */
|
||||
int iteration, /* interations for PBE alg */
|
||||
void *pwArg) /* context for password callback */
|
||||
{
|
||||
return PK11_ExportEncryptedPrivKeyInfoV2(slot, algTag, SEC_OID_UNKNOWN,
|
||||
SEC_OID_UNKNOWN, pwitem, pk,
|
||||
iteration, pwArg);
|
||||
}
|
||||
|
||||
/* V2 refers to PKCS #5 V2 here. If a PKCS #5 v1 or PKCS #12 pbe is passed
|
||||
* for pbeTag, then encTag and hashTag are ignored. If pbe is an encryption
|
||||
* algorithm, then PKCS #5 V2 is used with prfTag for the prf. If prfTag isn't
|
||||
* supplied prf will be SEC_OID_HMAC_SHA1 */
|
||||
SECKEYEncryptedPrivateKeyInfo *
|
||||
PK11_ExportEncryptedPrivateKeyInfoV2(
|
||||
PK11SlotInfo *slot, /* optional, encrypt key in this slot */
|
||||
SECOidTag pbeAlg, /* PBE algorithm to encrypt the with key */
|
||||
SECOidTag encAlg, /* Encryption algorithm to Encrypt the key with */
|
||||
SECOidTag prfAlg, /* HMAC algorithm for PRF*/
|
||||
SECItem *pwitem, /* password for PBE encryption */
|
||||
CERTCertificate *cert, /* wrap priv key for this user cert */
|
||||
int iteration, /* interations for PBE alg */
|
||||
void *pwArg) /* context for password callback */
|
||||
{
|
||||
SECKEYEncryptedPrivateKeyInfo *epki = NULL;
|
||||
SECKEYPrivateKey *pk = PK11_FindKeyByAnyCert(cert, pwArg);
|
||||
if (pk != NULL) {
|
||||
epki = PK11_ExportEncryptedPrivKeyInfoV2(slot, pbeAlg, encAlg, prfAlg,
|
||||
pwitem, pk, iteration,
|
||||
pwArg);
|
||||
SECKEY_DestroyPrivateKey(pk);
|
||||
}
|
||||
return epki;
|
||||
}
|
||||
|
||||
SECKEYEncryptedPrivateKeyInfo *
|
||||
PK11_ExportEncryptedPrivateKeyInfo(
|
||||
PK11SlotInfo *slot, /* optional, encrypt key in this slot */
|
||||
|
|
@ -2125,16 +2173,11 @@ PK11_ExportEncryptedPrivateKeyInfo(
|
|||
SECItem *pwitem, /* password for PBE encryption */
|
||||
CERTCertificate *cert, /* wrap priv key for this user cert */
|
||||
int iteration, /* interations for PBE alg */
|
||||
void *wincx) /* context for password callback ? */
|
||||
void *pwArg) /* context for password callback */
|
||||
{
|
||||
SECKEYEncryptedPrivateKeyInfo *epki = NULL;
|
||||
SECKEYPrivateKey *pk = PK11_FindKeyByAnyCert(cert, wincx);
|
||||
if (pk != NULL) {
|
||||
epki = PK11_ExportEncryptedPrivKeyInfo(slot, algTag, pwitem, pk,
|
||||
iteration, wincx);
|
||||
SECKEY_DestroyPrivateKey(pk);
|
||||
}
|
||||
return epki;
|
||||
return PK11_ExportEncryptedPrivateKeyInfoV2(slot, algTag, SEC_OID_UNKNOWN,
|
||||
SEC_OID_UNKNOWN, pwitem, cert,
|
||||
iteration, pwArg);
|
||||
}
|
||||
|
||||
SECItem *
|
||||
|
|
@ -2271,7 +2314,7 @@ PK11_ConvertSessionPrivKeyToTokenPrivKey(SECKEYPrivateKey *privk, void *wincx)
|
|||
|
||||
PK11_Authenticate(slot, PR_TRUE, wincx);
|
||||
rwsession = PK11_GetRWSession(slot);
|
||||
if (rwsession == CK_INVALID_SESSION) {
|
||||
if (rwsession == CK_INVALID_HANDLE) {
|
||||
PORT_SetError(SEC_ERROR_BAD_DATA);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -2548,7 +2591,7 @@ PK11_ListPublicKeysInSlot(PK11SlotInfo *slot, char *nickname)
|
|||
CK_ATTRIBUTE *attrs;
|
||||
CK_BBOOL ckTrue = CK_TRUE;
|
||||
CK_OBJECT_CLASS keyclass = CKO_PUBLIC_KEY;
|
||||
unsigned int tsize = 0;
|
||||
size_t tsize = 0;
|
||||
int objCount = 0;
|
||||
CK_OBJECT_HANDLE *key_ids;
|
||||
SECKEYPublicKeyList *keys;
|
||||
|
|
@ -2596,7 +2639,7 @@ PK11_ListPrivKeysInSlot(PK11SlotInfo *slot, char *nickname, void *wincx)
|
|||
CK_ATTRIBUTE *attrs;
|
||||
CK_BBOOL ckTrue = CK_TRUE;
|
||||
CK_OBJECT_CLASS keyclass = CKO_PRIVATE_KEY;
|
||||
unsigned int tsize = 0;
|
||||
size_t tsize = 0;
|
||||
int objCount = 0;
|
||||
CK_OBJECT_HANDLE *key_ids;
|
||||
SECKEYPrivateKeyList *keys;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue