if (!cms_kari_create_ephemeral_key(kari, recipPubKey))
return 0;
} else {
- /* Use originator key */
- CMS_OriginatorIdentifierOrKey *oik = ri->d.kari->originator;
+ /* Use originator key */
+ CMS_OriginatorIdentifierOrKey *oik = ri->d.kari->originator;
- if (originatorPrivKey == NULL && originator == NULL)
+ if (originatorPrivKey == NULL || originator == NULL)
return 0;
- if (flags & CMS_USE_ORIGINATOR_KEYID) {
- oik->type = CMS_OIK_KEYIDENTIFIER;
- oik->d.subjectKeyIdentifier = ASN1_OCTET_STRING_new();
- if (oik->d.subjectKeyIdentifier == NULL)
- return 0;
- if (!cms_set1_keyid(&oik->d.subjectKeyIdentifier, originator))
- return 0;
- } else {
- oik->type = CMS_REK_ISSUER_SERIAL;
- if (!cms_set1_ias(&oik->d.issuerAndSerialNumber, originator))
- return 0;
- }
-
- if (!cms_kari_set_originator_private_key(kari, originatorPrivKey))
- return 0;
+ if (flags & CMS_USE_ORIGINATOR_KEYID) {
+ oik->type = CMS_OIK_KEYIDENTIFIER;
+ oik->d.subjectKeyIdentifier = ASN1_OCTET_STRING_new();
+ if (oik->d.subjectKeyIdentifier == NULL)
+ return 0;
+ if (!cms_set1_keyid(&oik->d.subjectKeyIdentifier, originator))
+ return 0;
+ } else {
+ oik->type = CMS_REK_ISSUER_SERIAL;
+ if (!cms_set1_ias(&oik->d.issuerAndSerialNumber, originator))
+ return 0;
+ }
+
+ if (!cms_kari_set_originator_private_key(kari, originatorPrivKey))
+ return 0;
}
EVP_PKEY_up_ref(recipPubKey);