Exemplo n.º 1
0
static CRMFPKIArchiveOptions *
crmf_create_encr_pivkey_option(CRMFEncryptedKey *inEncryptedKey)
{
    CRMFPKIArchiveOptions *newArchOpt;
    SECStatus rv;

    newArchOpt = PORT_ZNew(CRMFPKIArchiveOptions);
    if (newArchOpt == NULL) {
        goto loser;
    }

    rv = crmf_copy_encryptedkey(NULL, inEncryptedKey,
                                &newArchOpt->option.encryptedKey);

    if (rv != SECSuccess) {
        goto loser;
    }
    newArchOpt->archOption = crmfEncryptedPrivateKey;
    return newArchOpt;
loser:
    if (newArchOpt != NULL) {
        CRMF_DestroyPKIArchiveOptions(newArchOpt);
    }
    return NULL;
}
Exemplo n.º 2
0
SECStatus
crmf_copy_pkiarchiveoptions(PLArenaPool *poolp,
                            CRMFPKIArchiveOptions *destOpt,
                            CRMFPKIArchiveOptions *srcOpt)
{
    SECStatus rv;
    destOpt->archOption = srcOpt->archOption;
    switch (srcOpt->archOption) {
    case crmfEncryptedPrivateKey:
        rv = crmf_copy_encryptedkey(poolp,
                                    &srcOpt->option.encryptedKey,
                                    &destOpt->option.encryptedKey);
        break;
    case crmfKeyGenParameters:
    case crmfArchiveRemGenPrivKey:
        /* We've got a union, so having a pointer to one is just
         * like having a pointer to the other one.
         */
        rv = SECITEM_CopyItem(poolp,
                              &destOpt->option.keyGenParameters,
                              &srcOpt->option.keyGenParameters);
        break;
    default:
        rv = SECFailure;
    }
    return rv;
}
Exemplo n.º 3
0
CRMFEncryptedKey *
CRMF_PKIArchiveOptionsGetEncryptedPrivKey(CRMFPKIArchiveOptions *inOpts)
{
    CRMFEncryptedKey *newEncrKey = NULL;
    SECStatus rv;

    PORT_Assert(inOpts != NULL);
    if (inOpts == NULL ||
        CRMF_PKIArchiveOptionsGetOptionType(inOpts) != crmfEncryptedPrivateKey) {
        return NULL;
    }
    newEncrKey = PORT_ZNew(CRMFEncryptedKey);
    if (newEncrKey == NULL) {
        goto loser;
    }
    rv = crmf_copy_encryptedkey(NULL, &inOpts->option.encryptedKey,
                                newEncrKey);
    if (rv != SECSuccess) {
        goto loser;
    }
    return newEncrKey;
loser:
    if (newEncrKey != NULL) {
        CRMF_DestroyEncryptedKey(newEncrKey);
    }
    return NULL;
}