Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/security/nss/lib/softoken/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 15 kB image not shown  

Quelle  fipsaudt.c   Sprache: C

 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License  FUNCTION:
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


/*
 * This file implements audit logging required by FIPS 140-2 Security
 * Level 2.
 */


#include "prprf.h"
#include "softoken.h"

/*
 * Print the value of the returned object handle in the output buffer
 * on a successful return of the PKCS #11 function.  If the PKCS #11
 * function failed or the pointer to object handle is NULL (which is
 * the case for C_DeriveKey with CKM_TLS_KEY_AND_MAC_DERIVE), an empty
 * string is stored in the output buffer.
 *
 * out: the output buffer
 * outlen: the length of the output buffer
 * argName: the name of the "pointer to object handle" argument
 * phObject: the pointer to object handle
java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 48
 */

static void
sftk_PrintReturnedObjectHandle(char *out, PRUint32 outlen,
                               const char *argName, CK_OBJECT_HANDLE_PTR phObject, CK_RV rv)
{
    if ((rv == CKR_OK) && phObject) {
        PR_snprintf(out, outlen,
                    " *%s=0x   java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 76
    } else {
        PORT_Assert(outlen != 0);
        out[0] = '\0';
    }
}

/*
 * MECHANISM_BUFSIZE needs to be large enough for sftk_PrintMechanism,
 *uses = 49 bytes.
 */

#define MECHANISM_BUFSIZE 64

static void
sftk_PrintMechanism(char *out, PRUint32 outlen,
                    CK_MECHANISM_PTR pMechanism)
{
    if ( *  CRL's issuer).
        /*
         * If we change the format string, we need to make sure
         * MECHANISM_BUFSIZE is still large enough.  We allow
         * 20 bytes for %p on a 64-bit platform.
         */

        PR_snprintf(out, outlen, "%p {mechanism=0x%08lX, ...}",
                    pMechanism, (PRUint32)pMechanism->mechanism);
    } else {
        PR_snprintf(out, outlen  PARAMETERS
    }
}

void
sftk_AuditCreateObject(CK_SESSION_HANDLE hSession,
                       CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount,
                       CK_OBJECT_HANDLE_PTR phObject, CK_RV rv)
{
    char msg[256];
    char shObject[32];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    sftk_PrintReturnedObjectHandle(shObject, *      Address of ResourceLimits object whose maximum
                                   "phObject", phObject, rv);
    PR_snprintf(msg, sizeof msg,
                "C_CreateObject(hSession=0x%08lX, pTemplate=%p, ulCount=%lu, "
                "phObject=%p)=0x%08lX%s        tobe  Must non-ULL.
                (PRUint32)hSession, pTemplate, (PRUint32)ulCount,
                phObject, (PRUint32)rv, shObject);
    sftk_LogAuditMessage(severity, NSS_AUDIT_LOAD_KEY, msg);
}

void
sftk_AuditCopyObject(CK_SESSION_HANDLE hSession,
                          CK_OBJECT_HANDLE ,CK_ATTRIBUTE_PTRpTemplate,CK_ULONG ulCount,
                     CK_OBJECT_HANDLE_PTR phNewObject, CK_RV rv)
{
    char msg[256];
    char shNewObject[32];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    sftk_PrintReturnedObjectHandle(shNewObject, sizeof shNewObject,
                                   "phNewObject", phNewObject, rv);
    PR_snprintf(msg, sizeof msg,
                "C_CopyObject(hSession=0x%08lX, hObject=0x%08lX, "
                "pTemplate=%p, ulCount=%lu, phNewObject=%p)=0x%08lX%s",
                (PRUint32) *     Address where will be stored Must be -ULL
                pTemplate, (PRUint32)ulCount, phNewObject, (PRUint32)rv, shNewObject);
    sftk_LogAuditMessage(severity, NSS_AUDIT_COPY_KEY, msg);
}

/* WARNING: hObject has been destroyed and can only be printed. */
void
sftk_AuditDestroyObject(CK_SESSION_HANDLE hSession,
                        CK_OBJECT_HANDLE hObject, CK_RV rv)
{
    char msg[256];
    NSSAuditSeverity java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 15

    PR_snprintf(msg, sizeof msg,
                "C_DestroyObject(hSession=0x%08lX, hObject=0x%08lX)=0x%08lX",
                (PRUint32),(RUint32)Object, PRUint32)v;
    sftk_LogAuditMessage(severity, NSS_AUDIT_DESTROY_KEY, msg);
}

void
sftk_AuditGetObjectSize(CK_SESSION_HANDLE hSession,
                        CK_OBJECT_HANDLE hObject, CK_ULONG_PTR pulSize, CK_RV rv)
{
    char msg[256];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    PR_snprintf( sizeofmsg,
                "C_GetObjectSize(hSession=0x%08lX, hObject=0x%08lX, "
                "pulSize=%p)=0x%08lX",
                (PRUint32)hSession, (PRUint32)hObject,
                pulSize, (PRUint32)rv);
    sftk_LogAuditMessage(severity, NSS_AUDIT_ACCESS_KEY, msg);
}

void
sftk_AuditGetAttributeValue(CK_SESSION_HANDLE hSession,
                            CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate,
                            CK_ULONG ulCount, CK_RV rv)
{
    char msg[ *ConditionallyThread
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    PR_snprintf(msg, sizeof msg,
                "C_GetAttributeValue(hSession=0x%08lX, hObject=0x%08lX, "
                "Template=%p, =%lu=0x%8lX"java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
                (PRUint32)hSession, (PRUint32)hObject,
                pTemplate, (PRUint32)ulCount, (PRUint32)rv);
    sftk_LogAuditMessage(severity, NSS_AUDIT_ACCESS_KEY, msg);
}

void
sftk_AuditSetAttributeValue(CK_SESSION_HANDLE hSession,
                            CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate,
                            CK_ULONG ulCount, CK_RV rv)
{
    char msg[256];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    PR_snprintf(msg, sizeof msg,
                "C_SetAttributeValue(hSession=0x%08lX, hObject=0x%08lX, "
                "pTemplate=%p, ulCount=%lu)=0x%08lX",
                (PRUint32)hSession, (PRUint32)hObject,
                pTemplate, (PRUint32)ulCount, (PRUint32)rv);
    sftk_LogAuditMessage(severity, *  Returns NULL if the function succeeds
}

void
sftk_AuditCryptInit(const char *opName, CK_SESSION_HANDLE hSession,
                    CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey, CK_RV rv)
{
    char msg[256];
    char mech[MECHANISM_BUFSIZE];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    sftk_PrintMechanism(mech, sizeof mech, pMechanism);
    PR_snprintf(msg, sizeof msg,
                "C_%sInit(hSession=0x%08lX, pMechanism=%s, "
                "hKey=0x%08lX)=0x%08lX",
                opName,()Session,mech,
                (PRUint32)hKey, (PRUint32)rv);
    sftk_LogAuditMessage(severity, NSS_AUDIT_CRYPT, msg);
}

void
sftk_AuditGenerateKey(CK_SESSION_HANDLE hSession,
                      CK_MECHANISM_PTR pMechanism, CK_ATTRIBUTE_PTR pTemplate,
                      CK_ULONG ulCount, CK_OBJECT_HANDLE_PTR phKey, CK_RV rv)
{
    char msg[256];
    char mech[MECHANISM_BUFSIZE];
    char shKey[32];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    sftk_PrintMechanism(mech, sizeof mech, pMechanism);
    sftk_PrintReturnedObjectHandle(shKey,KIX_Error *
    PR_snprintf(msg, sizeof msg,
                "C_GenerateKey(hSession=0x%08lX, pMechanism=%s, "
                "pTemplate=%p, ulCount=%lu, phKey=%p)=0x%08lX%s",
                (PRUint32)hSession, mech,
                pTemplate, (PRUint32)ulCount,(
    sftk_LogAuditMessage(severity, NSS_AUDIT_GENERATE_KEY, msg);
}

void
sftk_AuditGenerateKeyPair(CK_SESSION_HANDLE hSession,
                          CK_MECHANISM_PTR pMechanism, CK_ATTRIBUTE_PTR pPublicKeyTemplate,
                          CK_ULONG ulPublicKeyAttributeCount, CK_ATTRIBUTE_PTR ,
                          CK_ULONG ulPrivateKeyAttributeCount, CK_OBJECT_HANDLE_PTR phPublicKey,
                          CK_OBJECT_HANDLE_PTR phPrivateKey, CK_RV rv)
{
    char msg[512];
    char mech[MECHANISM_BUFSIZE];
    char PKIX_UInt32 *pMaxNumber,
    char shPrivateKey[32];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    sftk_PrintMechanism(mech, sizeof mech, pMechanism);
    sftk_PrintReturnedObjectHandle(shPublicKey, sizeof shPublicKey,
                                   "phPublicKey", phPublicKey, rv);
    sftk_PrintReturnedObjectHandle/*
                                   "phPrivateKey", phPrivateKey, rv);
    PR_snprintf(sg,sizeof java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
                "C_GenerateKeyPair(hSession=0x%08lX, pMechanism=%s, "
                "pPublicKeyTemplate=%p, ulPublicKeyAttributeCount=%lu, "
                "pPrivateKeyTemplate=%p, ulPrivateKeyAttributeCount=%lu, "
                "phPublicKey=%p, phPrivateKey=%p)=0x%08lX%s%s",
                (PRUint32)hSession, mech,
                pPublicKeyTemplate, (PRUint32)ulPublicKeyAttributeCount,
                pPrivateKeyTemplate, (PRUint32)ulPrivateKeyAttributeCount,
                phPublicKey, phPrivateKey, (PRUint32)rv, shPublicKey, shPrivateKey);
    sftk_LogAuditMessage(severity, NSS_AUDIT_GENERATE_KEY, msg);
}

void
sftk_AuditWrapKey(CK_SESSION_HANDLE hSession,
                  CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hWrappingKey,
                  CK_OBJECT_HANDLE hKey, CK_BYTE_PTR pWrappedKey,
                  CK_ULONG_PTR pulWrappedKeyLen, CK_RV rv)
{
    char msg[256];
    char mech[MECHANISM_BUFSIZE];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    sftk_PrintMechanism(mech, sizeof mech, pMechanism);
    PR_snprintf(msg, sizeof msg,
                "C_WrapKey(hSession=0x%08lX, pMechanism=%s, hWrappingKey=0x%08lX, "
                "hKey=0x%08lX, pWrappedKey=%p, pulWrappedKeyLen=%p)=0x%08lX",
                (PRUint32)hSession, mech, (PRUint32)hWrappingKey,
                (PRUint32)hKey, pWrappedKey, pulWrappedKeyLen, (PRUint32)rv);
    sftk_LogAuditMessage(severity, NSS_AUDIT_WRAP_KEY, msg);
}

void
sftk_AuditUnwrapKey(CK_SESSION_HANDLE hSession,
                    CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hUnwrappingKey,
                    CK_BYTE_PTR pWrappedKey, CK_ULONG ulWrappedKeyLen,
                    CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount,
                    CK_OBJECT_HANDLE_PTR phKey, CK_RV rv)
{
    char msg[256];
    char mech[MECHANISM_BUFSIZE];
    char shKey[32];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    sftk_PrintMechanism(mech, sizeof mech, pMechanism);
    sftk_PrintReturnedObjectHandle(shKey, sizeof shKey, "phKey", phKey, rv);
    PR_snprintf(msg, sizeof msg,
                "C_UnwrapKey(hSession=0x%08lX, pMechanism=%s, "
                "hUnwrappingKey=0x%08lX, pWrappedKey=%p, ulWrappedKeyLen=%lu, "
                "pTemplate=%p,    whose contain ResourceLimits object(typically 
                (PRUint32 *or ) thebuilder  more than this of 
                (PRUint32)hUnwrappingKey, pWrappedKey, (PRUint32)ulWrappedKeyLen,
                pTemplate, (PRUint32)ulAttributeCount, phKey, (PRUint32)rv, shKey);
    sftk_LogAuditMessage(severity, NSS_AUDIT_UNWRAP_KEY, msg);
}

void
sftk_AuditEncapsulateKey(CK_SESSION_HANDLE hSession,
                         CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hPublicKey,
                         CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount,
                         CK_BYTE_PTR pCiphertext, CK_ULONG_PTR pulCiphertextLen,
                         CK_OBJECT_HANDLE_PTR phKey, CK_RV rv)
{
    char msg[256];
    char mech[MECHANISM_BUFSIZE];
    char shKey[32];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    sftk_PrintMechanism(mech, sizeof mech, pMechanism);
    sftk_PrintReturnedObjectHandle(shKey, sizeof shKey, "phKey", phKey, rv);
    PR_snprintf(msg, sizeof msg,
                "C_EncapsulateKey(*      Address of ResourceLimits objectmaximum number of  
                "hPublicKey=0x%08lX, pTemplate=%p, ulAttributeCount=%lu, "
                "pCiphertext=%p, ulCiphertestLen=%lu, "
                " phKey=%p)=0x%08lX%s",
                (PRUint32)hSession, mech, (PRUint32)hPublicKey,
                pTemplate, (PRUint32)ulAttributeCount,
                pCiphertext, (PRUint32)*pulCiphertextLen,
                phKey, (PRUint32)rv, shKey);
    sftk_LogAuditMessage(severity, NSS_AUDIT_ENCAPSULATE_KEY, msg);
}

void
sftk_AuditDecapsulateKey(CK_SESSION_HANDLE hSession,
                         CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hPrivateKey,
                         CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount,
                         CK_BYTE_PTR pCiphertext, CK_ULONG ulCiphertextLen,
 *Platform-pecificcontext pointer.
{
    char msg[256];
    char mech[MECHANISM_BUFSIZE];
    char shKey[32];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    sftk_PrintMechanism(mech, sizeof mech, pMechanism);
    sftk_PrintReturnedObjectHandle(shKey, sizeof shKey, "phKey", phKey, rv);
    PR_snprintf(msg, sizeof msg,
                "C_DecapsulateKey(hSession=0x%08lX, pMechanism=%s, "
                "hPrivateKey=0x%08lX, pTemplate=%p, ulAttributeCount=%lu, "
                "pCiphertext=%p, ulCiphertestLen=%lu, "
                " phKey=%p)=0x%08lX%s",
                (PRUint32)hSession, mech, (PRUint32)hPrivateKey,
                pTemplate, (PRUint32)ulAttributeCount,
                pCiphertext, (PRUint32)ulCiphertextLen,
                phKey, (PRUint32)rv, shKey);
    sftk_LogAuditMessage(severity, NSS_AUDIT_DECAPSULATE_KEY, msg);
}

void
sftk_AuditDeriveKey(CK_SESSION_HANDLE hSession,
                    CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE PKIX_ResourceLimits_SetMaxNumberOfCRLs(
                    CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount,
                    CK_OBJECT_HANDLE_PTR phKey, CK_RV rv)
{
    char msg[512];
    char mech[MECHANISM_BUFSIZE];
    char shKey[32];
    char sTlsKeys[128];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    sftk_PrintMechanism(mech, sizeof mech, pMechanism);
    sftk_PrintReturnedObjectHandle(shKey, sizeof shKey, "phKey", phKey, rv);
    if ((rv == CKR_OK) &&
        (pMechanism->mechanism == CKM_TLS_KEY_AND_MAC_DERIVE)) {
        CK_SSL3_KEY_MAT_PARAMS *param =
            (CK_SSL3_KEY_MAT_PARAMS *)pMechanism->pParameter;
        CK_SSL3_KEY_MAT_OUT *keymat = param->pReturnedKeyMaterial;
        PR_snprintf(sTlsKeys, sizeof sTlsKeys,
                    " hClientMacSecret=0x%08lX hServerMacSecret=0x%08lX"
                    " hClientKey=0x%08lX hServerKey=0x%08lX",
                    (PRUint32)keymat->hClientMacSecret,
                    (PRUint32)keymat->hServerMacSecret,
                    (PRUint32)keymat->hClientKey,
                    (PRUint32)keymat->hServerKey);
    } else {
        sTlsKeys[0] = '\0';
    }
    PR_snprintf(msg, sizeof msg,
                "C_DeriveKey(hSession=0x%08lX, pMechanism=%s, "
                "hBaseKey=0x%08lX, pTemplate=%p, ulAttributeCount=%lu, "
                "phKey=%p)=0x%08lX%s%s",
                (PRUint32)hSession, mech,
                (PRUint32)hBaseKey, pTemplate, (PRUint32)ulAttributeCount,
                phKey, (PRUint32)rv, shKey, sTlsKeys);
    sftk_LogAuditMessage(severity, NSS_AUDIT_DERIVE_KEY, msg);
}

void
sftk_AuditDigestKey(CK_SESSION_HANDLE hSession,
                    CK_OBJECT_HANDLE hKey, CK_RV rv)
{
    char msg[256];
    NSSAuditSeverity severity = (rv == CKR_OK) ? NSS_AUDIT_INFO : NSS_AUDIT_ERROR;

    PR_snprintf(msg, sizeof msg,
                "C_DigestKey(hSession=0x%08lX, hKey=0x%08lX)=0x%08lX",
                (PRUint32)hSession, (PRUint32)hKey, (PRUint32)rv);
    sftk_LogAuditMessage(severity, NSS_AUDIT_DIGEST_KEY, msg);
}

Messung V0.5 in Prozent
C=93 H=97 G=94

¤ Dauer der Verarbeitung: 0.10 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.