| 1 |
/* |
| 2 |
* Copyright 2008-2026 The OpenSSL Project Authors. All Rights Reserved. |
| 3 |
* |
| 4 |
* Licensed under the Apache License 2.0 (the "License"). You may not use |
| 5 |
* this file except in compliance with the License. You can obtain a copy |
| 6 |
* in the file LICENSE in the source distribution or at |
| 7 |
* https://www.openssl.org/source/license.html |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef OSSL_CRYPTO_CMS_LOCAL_H |
| 11 |
#define OSSL_CRYPTO_CMS_LOCAL_H |
| 12 |
|
| 13 |
#include <openssl/x509.h> |
| 14 |
|
| 15 |
/* |
| 16 |
* Cryptographic message syntax (CMS) structures: taken from RFC3852 |
| 17 |
*/ |
| 18 |
|
| 19 |
/* Forward references */ |
| 20 |
|
| 21 |
typedef struct CMS_IssuerAndSerialNumber_st CMS_IssuerAndSerialNumber; |
| 22 |
typedef struct CMS_EncapsulatedContentInfo_st CMS_EncapsulatedContentInfo; |
| 23 |
typedef struct CMS_SignerIdentifier_st CMS_SignerIdentifier; |
| 24 |
typedef struct CMS_OtherRevocationInfoFormat_st CMS_OtherRevocationInfoFormat; |
| 25 |
typedef struct CMS_OriginatorInfo_st CMS_OriginatorInfo; |
| 26 |
typedef struct CMS_EncryptedContentInfo_st CMS_EncryptedContentInfo; |
| 27 |
typedef struct CMS_DigestedData_st CMS_DigestedData; |
| 28 |
typedef struct CMS_EncryptedData_st CMS_EncryptedData; |
| 29 |
typedef struct CMS_AuthenticatedData_st CMS_AuthenticatedData; |
| 30 |
typedef struct CMS_AuthEnvelopedData_st CMS_AuthEnvelopedData; |
| 31 |
typedef struct CMS_CompressedData_st CMS_CompressedData; |
| 32 |
typedef struct CMS_OtherCertificateFormat_st CMS_OtherCertificateFormat; |
| 33 |
typedef struct CMS_KeyTransRecipientInfo_st CMS_KeyTransRecipientInfo; |
| 34 |
typedef struct CMS_OriginatorPublicKey_st CMS_OriginatorPublicKey; |
| 35 |
typedef struct CMS_OriginatorIdentifierOrKey_st CMS_OriginatorIdentifierOrKey; |
| 36 |
typedef struct CMS_KeyAgreeRecipientInfo_st CMS_KeyAgreeRecipientInfo; |
| 37 |
typedef struct CMS_RecipientKeyIdentifier_st CMS_RecipientKeyIdentifier; |
| 38 |
typedef struct CMS_KeyAgreeRecipientIdentifier_st CMS_KeyAgreeRecipientIdentifier; |
| 39 |
typedef struct CMS_KEKIdentifier_st CMS_KEKIdentifier; |
| 40 |
typedef struct CMS_KEKRecipientInfo_st CMS_KEKRecipientInfo; |
| 41 |
typedef struct CMS_PasswordRecipientInfo_st CMS_PasswordRecipientInfo; |
| 42 |
typedef struct CMS_OtherRecipientInfo_st CMS_OtherRecipientInfo; |
| 43 |
typedef struct CMS_KEMRecipientInfo_st CMS_KEMRecipientInfo; |
| 44 |
typedef struct CMS_ReceiptsFrom_st CMS_ReceiptsFrom; |
| 45 |
typedef struct CMS_CTX_st CMS_CTX; |
| 46 |
|
| 47 |
struct CMS_CTX_st { |
| 48 |
OSSL_LIB_CTX *libctx; |
| 49 |
char *propq; |
| 50 |
}; |
| 51 |
|
| 52 |
struct CMS_ContentInfo_st { |
| 53 |
ASN1_OBJECT *contentType; |
| 54 |
union { |
| 55 |
ASN1_OCTET_STRING *data; |
| 56 |
CMS_SignedData *signedData; |
| 57 |
CMS_EnvelopedData *envelopedData; |
| 58 |
CMS_DigestedData *digestedData; |
| 59 |
CMS_EncryptedData *encryptedData; |
| 60 |
CMS_AuthEnvelopedData *authEnvelopedData; |
| 61 |
CMS_AuthenticatedData *authenticatedData; |
| 62 |
CMS_CompressedData *compressedData; |
| 63 |
ASN1_TYPE *other; |
| 64 |
/* Other types ... */ |
| 65 |
void *otherData; |
| 66 |
} d; |
| 67 |
CMS_CTX ctx; |
| 68 |
}; |
| 69 |
|
| 70 |
DEFINE_STACK_OF(CMS_CertificateChoices) |
| 71 |
|
| 72 |
struct CMS_SignedData_st { |
| 73 |
int32_t version; |
| 74 |
STACK_OF(X509_ALGOR) *digestAlgorithms; |
| 75 |
CMS_EncapsulatedContentInfo *encapContentInfo; |
| 76 |
STACK_OF(CMS_CertificateChoices) *certificates; |
| 77 |
STACK_OF(CMS_RevocationInfoChoice) *crls; |
| 78 |
STACK_OF(CMS_SignerInfo) *signerInfos; |
| 79 |
}; |
| 80 |
|
| 81 |
struct CMS_EncapsulatedContentInfo_st { |
| 82 |
ASN1_OBJECT *eContentType; |
| 83 |
ASN1_OCTET_STRING *eContent; |
| 84 |
/* Set to 1 if incomplete structure only part set up */ |
| 85 |
int partial; |
| 86 |
}; |
| 87 |
|
| 88 |
struct CMS_SignerInfo_st { |
| 89 |
int32_t version; |
| 90 |
CMS_SignerIdentifier *sid; |
| 91 |
X509_ALGOR *digestAlgorithm; |
| 92 |
STACK_OF(X509_ATTRIBUTE) *signedAttrs; |
| 93 |
X509_ALGOR *signatureAlgorithm; |
| 94 |
ASN1_OCTET_STRING *signature; |
| 95 |
STACK_OF(X509_ATTRIBUTE) *unsignedAttrs; |
| 96 |
/* Signing certificate and key */ |
| 97 |
X509 *signer; |
| 98 |
EVP_PKEY *pkey; |
| 99 |
/* Digest and public key context for alternative parameters */ |
| 100 |
EVP_MD_CTX *mctx; |
| 101 |
EVP_PKEY_CTX *pctx; |
| 102 |
const CMS_CTX *cms_ctx; |
| 103 |
/* Set to 1 if signing time attribute is to be omitted */ |
| 104 |
int omit_signing_time; |
| 105 |
}; |
| 106 |
|
| 107 |
struct CMS_SignerIdentifier_st { |
| 108 |
int type; |
| 109 |
union { |
| 110 |
CMS_IssuerAndSerialNumber *issuerAndSerialNumber; |
| 111 |
ASN1_OCTET_STRING *subjectKeyIdentifier; |
| 112 |
} d; |
| 113 |
}; |
| 114 |
|
| 115 |
struct CMS_EnvelopedData_st { |
| 116 |
int32_t version; |
| 117 |
CMS_OriginatorInfo *originatorInfo; |
| 118 |
STACK_OF(CMS_RecipientInfo) *recipientInfos; |
| 119 |
CMS_EncryptedContentInfo *encryptedContentInfo; |
| 120 |
STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs; |
| 121 |
}; |
| 122 |
|
| 123 |
struct CMS_OriginatorInfo_st { |
| 124 |
STACK_OF(CMS_CertificateChoices) *certificates; |
| 125 |
STACK_OF(CMS_RevocationInfoChoice) *crls; |
| 126 |
}; |
| 127 |
|
| 128 |
struct CMS_EncryptedContentInfo_st { |
| 129 |
ASN1_OBJECT *contentType; |
| 130 |
X509_ALGOR *contentEncryptionAlgorithm; |
| 131 |
ASN1_OCTET_STRING *encryptedContent; |
| 132 |
/* Content encryption algorithm, key and tag */ |
| 133 |
const EVP_CIPHER *cipher; |
| 134 |
unsigned char *key; |
| 135 |
size_t keylen; |
| 136 |
unsigned char *tag; |
| 137 |
size_t taglen; |
| 138 |
/* Set to 1 if we are debugging decrypt and don't fake keys for MMA */ |
| 139 |
int debug; |
| 140 |
/* Set to 1 if we have no cert and need extra safety measures for MMA */ |
| 141 |
int havenocert; |
| 142 |
}; |
| 143 |
|
| 144 |
struct CMS_RecipientInfo_st { |
| 145 |
/* |
| 146 |
* Type which the RecipientInfo is encoded with. OtherRecipientInfo |
| 147 |
* encompasses different types, specified by 'type' below. |
| 148 |
*/ |
| 149 |
int encoded_type; |
| 150 |
union { |
| 151 |
CMS_KeyTransRecipientInfo *ktri; |
| 152 |
CMS_KeyAgreeRecipientInfo *kari; |
| 153 |
CMS_KEKRecipientInfo *kekri; |
| 154 |
CMS_PasswordRecipientInfo *pwri; |
| 155 |
CMS_OtherRecipientInfo *ori; |
| 156 |
} d; |
| 157 |
/* internal type, including ORI types */ |
| 158 |
int type; |
| 159 |
}; |
| 160 |
|
| 161 |
typedef CMS_SignerIdentifier CMS_RecipientIdentifier; |
| 162 |
|
| 163 |
struct CMS_KeyTransRecipientInfo_st { |
| 164 |
int32_t version; |
| 165 |
CMS_RecipientIdentifier *rid; |
| 166 |
X509_ALGOR *keyEncryptionAlgorithm; |
| 167 |
ASN1_OCTET_STRING *encryptedKey; |
| 168 |
/* Recipient Key and cert */ |
| 169 |
X509 *recip; |
| 170 |
EVP_PKEY *pkey; |
| 171 |
/* Public key context for this operation */ |
| 172 |
EVP_PKEY_CTX *pctx; |
| 173 |
const CMS_CTX *cms_ctx; |
| 174 |
}; |
| 175 |
|
| 176 |
struct CMS_KeyAgreeRecipientInfo_st { |
| 177 |
int32_t version; |
| 178 |
CMS_OriginatorIdentifierOrKey *originator; |
| 179 |
ASN1_OCTET_STRING *ukm; |
| 180 |
X509_ALGOR *keyEncryptionAlgorithm; |
| 181 |
STACK_OF(CMS_RecipientEncryptedKey) *recipientEncryptedKeys; |
| 182 |
/* Public key context associated with current operation */ |
| 183 |
EVP_PKEY_CTX *pctx; |
| 184 |
/* Cipher context for CEK wrapping */ |
| 185 |
EVP_CIPHER_CTX *ctx; |
| 186 |
const CMS_CTX *cms_ctx; |
| 187 |
}; |
| 188 |
|
| 189 |
struct CMS_OriginatorIdentifierOrKey_st { |
| 190 |
int type; |
| 191 |
union { |
| 192 |
CMS_IssuerAndSerialNumber *issuerAndSerialNumber; |
| 193 |
ASN1_OCTET_STRING *subjectKeyIdentifier; |
| 194 |
CMS_OriginatorPublicKey *originatorKey; |
| 195 |
} d; |
| 196 |
}; |
| 197 |
|
| 198 |
struct CMS_OriginatorPublicKey_st { |
| 199 |
X509_ALGOR *algorithm; |
| 200 |
ASN1_BIT_STRING *publicKey; |
| 201 |
}; |
| 202 |
|
| 203 |
struct CMS_RecipientEncryptedKey_st { |
| 204 |
CMS_KeyAgreeRecipientIdentifier *rid; |
| 205 |
ASN1_OCTET_STRING *encryptedKey; |
| 206 |
/* Public key associated with this recipient */ |
| 207 |
EVP_PKEY *pkey; |
| 208 |
}; |
| 209 |
|
| 210 |
struct CMS_KeyAgreeRecipientIdentifier_st { |
| 211 |
int type; |
| 212 |
union { |
| 213 |
CMS_IssuerAndSerialNumber *issuerAndSerialNumber; |
| 214 |
CMS_RecipientKeyIdentifier *rKeyId; |
| 215 |
} d; |
| 216 |
}; |
| 217 |
|
| 218 |
struct CMS_RecipientKeyIdentifier_st { |
| 219 |
ASN1_OCTET_STRING *subjectKeyIdentifier; |
| 220 |
ASN1_GENERALIZEDTIME *date; |
| 221 |
CMS_OtherKeyAttribute *other; |
| 222 |
}; |
| 223 |
|
| 224 |
struct CMS_KEKRecipientInfo_st { |
| 225 |
int32_t version; |
| 226 |
CMS_KEKIdentifier *kekid; |
| 227 |
X509_ALGOR *keyEncryptionAlgorithm; |
| 228 |
ASN1_OCTET_STRING *encryptedKey; |
| 229 |
/* Extra info: symmetric key to use */ |
| 230 |
unsigned char *key; |
| 231 |
size_t keylen; |
| 232 |
const CMS_CTX *cms_ctx; |
| 233 |
}; |
| 234 |
|
| 235 |
struct CMS_KEKIdentifier_st { |
| 236 |
ASN1_OCTET_STRING *keyIdentifier; |
| 237 |
ASN1_GENERALIZEDTIME *date; |
| 238 |
CMS_OtherKeyAttribute *other; |
| 239 |
}; |
| 240 |
|
| 241 |
struct CMS_PasswordRecipientInfo_st { |
| 242 |
int32_t version; |
| 243 |
X509_ALGOR *keyDerivationAlgorithm; |
| 244 |
X509_ALGOR *keyEncryptionAlgorithm; |
| 245 |
ASN1_OCTET_STRING *encryptedKey; |
| 246 |
/* Extra info: password to use */ |
| 247 |
unsigned char *pass; |
| 248 |
size_t passlen; |
| 249 |
const CMS_CTX *cms_ctx; |
| 250 |
}; |
| 251 |
|
| 252 |
struct CMS_OtherRecipientInfo_st { |
| 253 |
ASN1_OBJECT *oriType; |
| 254 |
union { |
| 255 |
/* NID_id_smime_ori_kem */ |
| 256 |
CMS_KEMRecipientInfo *kemri; |
| 257 |
/* anything else */ |
| 258 |
ASN1_TYPE *other; |
| 259 |
} d; |
| 260 |
}; |
| 261 |
|
| 262 |
struct CMS_KEMRecipientInfo_st { |
| 263 |
int32_t version; |
| 264 |
CMS_RecipientIdentifier *rid; |
| 265 |
X509_ALGOR *kem; |
| 266 |
ASN1_OCTET_STRING *kemct; |
| 267 |
X509_ALGOR *kdf; |
| 268 |
uint32_t kekLength; |
| 269 |
ASN1_OCTET_STRING *ukm; |
| 270 |
X509_ALGOR *wrap; |
| 271 |
ASN1_OCTET_STRING *encryptedKey; |
| 272 |
/* Public key context associated with current operation */ |
| 273 |
EVP_PKEY_CTX *pctx; |
| 274 |
/* Cipher context for CEK wrapping */ |
| 275 |
EVP_CIPHER_CTX *ctx; |
| 276 |
const CMS_CTX *cms_ctx; |
| 277 |
}; |
| 278 |
|
| 279 |
struct CMS_DigestedData_st { |
| 280 |
int32_t version; |
| 281 |
X509_ALGOR *digestAlgorithm; |
| 282 |
CMS_EncapsulatedContentInfo *encapContentInfo; |
| 283 |
ASN1_OCTET_STRING *digest; |
| 284 |
}; |
| 285 |
|
| 286 |
struct CMS_EncryptedData_st { |
| 287 |
int32_t version; |
| 288 |
CMS_EncryptedContentInfo *encryptedContentInfo; |
| 289 |
STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs; |
| 290 |
}; |
| 291 |
|
| 292 |
struct CMS_AuthenticatedData_st { |
| 293 |
int32_t version; |
| 294 |
CMS_OriginatorInfo *originatorInfo; |
| 295 |
STACK_OF(CMS_RecipientInfo) *recipientInfos; |
| 296 |
X509_ALGOR *macAlgorithm; |
| 297 |
X509_ALGOR *digestAlgorithm; |
| 298 |
CMS_EncapsulatedContentInfo *encapContentInfo; |
| 299 |
STACK_OF(X509_ATTRIBUTE) *authAttrs; |
| 300 |
ASN1_OCTET_STRING *mac; |
| 301 |
STACK_OF(X509_ATTRIBUTE) *unauthAttrs; |
| 302 |
}; |
| 303 |
|
| 304 |
struct CMS_AuthEnvelopedData_st { |
| 305 |
int32_t version; |
| 306 |
CMS_OriginatorInfo *originatorInfo; |
| 307 |
STACK_OF(CMS_RecipientInfo) *recipientInfos; |
| 308 |
CMS_EncryptedContentInfo *authEncryptedContentInfo; |
| 309 |
STACK_OF(X509_ATTRIBUTE) *authAttrs; |
| 310 |
ASN1_OCTET_STRING *mac; |
| 311 |
STACK_OF(X509_ATTRIBUTE) *unauthAttrs; |
| 312 |
}; |
| 313 |
|
| 314 |
struct CMS_CompressedData_st { |
| 315 |
int32_t version; |
| 316 |
X509_ALGOR *compressionAlgorithm; |
| 317 |
STACK_OF(CMS_RecipientInfo) *recipientInfos; |
| 318 |
CMS_EncapsulatedContentInfo *encapContentInfo; |
| 319 |
}; |
| 320 |
|
| 321 |
struct CMS_RevocationInfoChoice_st { |
| 322 |
int type; |
| 323 |
union { |
| 324 |
X509_CRL *crl; |
| 325 |
CMS_OtherRevocationInfoFormat *other; |
| 326 |
} d; |
| 327 |
}; |
| 328 |
|
| 329 |
#define CMS_REVCHOICE_CRL 0 |
| 330 |
#define CMS_REVCHOICE_OTHER 1 |
| 331 |
|
| 332 |
struct CMS_OtherRevocationInfoFormat_st { |
| 333 |
ASN1_OBJECT *otherRevInfoFormat; |
| 334 |
ASN1_TYPE *otherRevInfo; |
| 335 |
}; |
| 336 |
|
| 337 |
struct CMS_CertificateChoices { |
| 338 |
int type; |
| 339 |
union { |
| 340 |
X509 *certificate; |
| 341 |
ASN1_STRING *extendedCertificate; /* Obsolete */ |
| 342 |
ASN1_STRING *v1AttrCert; /* Left encoded for now */ |
| 343 |
ASN1_STRING *v2AttrCert; /* Left encoded for now */ |
| 344 |
CMS_OtherCertificateFormat *other; |
| 345 |
} d; |
| 346 |
}; |
| 347 |
|
| 348 |
#define CMS_CERTCHOICE_CERT 0 |
| 349 |
#define CMS_CERTCHOICE_EXCERT 1 |
| 350 |
#define CMS_CERTCHOICE_V1ACERT 2 |
| 351 |
#define CMS_CERTCHOICE_V2ACERT 3 |
| 352 |
#define CMS_CERTCHOICE_OTHER 4 |
| 353 |
|
| 354 |
struct CMS_OtherCertificateFormat_st { |
| 355 |
ASN1_OBJECT *otherCertFormat; |
| 356 |
ASN1_TYPE *otherCert; |
| 357 |
}; |
| 358 |
|
| 359 |
/* |
| 360 |
* This is also defined in pkcs7.h but we duplicate it to allow the CMS code |
| 361 |
* to be independent of PKCS#7 |
| 362 |
*/ |
| 363 |
|
| 364 |
struct CMS_IssuerAndSerialNumber_st { |
| 365 |
X509_NAME *issuer; |
| 366 |
ASN1_INTEGER *serialNumber; |
| 367 |
}; |
| 368 |
|
| 369 |
struct CMS_OtherKeyAttribute_st { |
| 370 |
ASN1_OBJECT *keyAttrId; |
| 371 |
ASN1_TYPE *keyAttr; |
| 372 |
}; |
| 373 |
|
| 374 |
/* ESS structures */ |
| 375 |
|
| 376 |
struct CMS_ReceiptRequest_st { |
| 377 |
ASN1_OCTET_STRING *signedContentIdentifier; |
| 378 |
CMS_ReceiptsFrom *receiptsFrom; |
| 379 |
STACK_OF(GENERAL_NAMES) *receiptsTo; |
| 380 |
}; |
| 381 |
|
| 382 |
struct CMS_ReceiptsFrom_st { |
| 383 |
int type; |
| 384 |
union { |
| 385 |
int32_t allOrFirstTier; |
| 386 |
STACK_OF(GENERAL_NAMES) *receiptList; |
| 387 |
} d; |
| 388 |
}; |
| 389 |
|
| 390 |
struct CMS_Receipt_st { |
| 391 |
int32_t version; |
| 392 |
ASN1_OBJECT *contentType; |
| 393 |
ASN1_OCTET_STRING *signedContentIdentifier; |
| 394 |
ASN1_OCTET_STRING *originatorSignatureValue; |
| 395 |
}; |
| 396 |
|
| 397 |
DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo) |
| 398 |
DECLARE_ASN1_ITEM(CMS_SignerInfo) |
| 399 |
DECLARE_ASN1_ITEM(CMS_EncryptedContentInfo) |
| 400 |
DECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber) |
| 401 |
DECLARE_ASN1_ITEM(CMS_Attributes_Sign) |
| 402 |
DECLARE_ASN1_ITEM(CMS_Attributes_Verify) |
| 403 |
DECLARE_ASN1_ITEM(CMS_RecipientInfo) |
| 404 |
DECLARE_ASN1_ITEM(CMS_PasswordRecipientInfo) |
| 405 |
DECLARE_ASN1_ALLOC_FUNCTIONS(CMS_IssuerAndSerialNumber) |
| 406 |
|
| 407 |
#define CMS_SIGNERINFO_ISSUER_SERIAL 0 |
| 408 |
#define CMS_SIGNERINFO_KEYIDENTIFIER 1 |
| 409 |
|
| 410 |
#define CMS_RECIPINFO_ISSUER_SERIAL 0 |
| 411 |
#define CMS_RECIPINFO_KEYIDENTIFIER 1 |
| 412 |
|
| 413 |
#define CMS_REK_ISSUER_SERIAL 0 |
| 414 |
#define CMS_REK_KEYIDENTIFIER 1 |
| 415 |
|
| 416 |
#define CMS_OIK_ISSUER_SERIAL 0 |
| 417 |
#define CMS_OIK_KEYIDENTIFIER 1 |
| 418 |
#define CMS_OIK_PUBKEY 2 |
| 419 |
|
| 420 |
BIO *ossl_cms_content_bio(CMS_ContentInfo *cms); |
| 421 |
const CMS_CTX *ossl_cms_get0_cmsctx(const CMS_ContentInfo *cms); |
| 422 |
OSSL_LIB_CTX *ossl_cms_ctx_get0_libctx(const CMS_CTX *ctx); |
| 423 |
const char *ossl_cms_ctx_get0_propq(const CMS_CTX *ctx); |
| 424 |
void ossl_cms_resolve_libctx(CMS_ContentInfo *ci); |
| 425 |
|
| 426 |
CMS_ContentInfo *ossl_cms_Data_create(OSSL_LIB_CTX *ctx, const char *propq); |
| 427 |
int ossl_cms_DataFinal(CMS_ContentInfo *cms, BIO *cmsbio, |
| 428 |
const unsigned char *precomp_md, |
| 429 |
unsigned int precomp_mdlen); |
| 430 |
|
| 431 |
CMS_ContentInfo *ossl_cms_DigestedData_create(const EVP_MD *md, |
| 432 |
OSSL_LIB_CTX *libctx, |
| 433 |
const char *propq); |
| 434 |
BIO *ossl_cms_DigestedData_init_bio(const CMS_ContentInfo *cms); |
| 435 |
int ossl_cms_DigestedData_do_final(const CMS_ContentInfo *cms, |
| 436 |
BIO *chain, int verify); |
| 437 |
|
| 438 |
BIO *ossl_cms_SignedData_init_bio(CMS_ContentInfo *cms); |
| 439 |
int ossl_cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain, |
| 440 |
const unsigned char *precomp_md, |
| 441 |
unsigned int precomp_mdlen); |
| 442 |
int ossl_cms_set1_SignerIdentifier(CMS_SignerIdentifier *sid, X509 *cert, |
| 443 |
int type, const CMS_CTX *ctx); |
| 444 |
int ossl_cms_SignerIdentifier_get0_signer_id(CMS_SignerIdentifier *sid, |
| 445 |
ASN1_OCTET_STRING **keyid, |
| 446 |
X509_NAME **issuer, |
| 447 |
ASN1_INTEGER **sno); |
| 448 |
int ossl_cms_SignerIdentifier_cert_cmp(CMS_SignerIdentifier *sid, X509 *cert); |
| 449 |
|
| 450 |
CMS_ContentInfo *ossl_cms_CompressedData_create(int comp_nid, |
| 451 |
OSSL_LIB_CTX *libctx, |
| 452 |
const char *propq); |
| 453 |
BIO *ossl_cms_CompressedData_init_bio(const CMS_ContentInfo *cms); |
| 454 |
|
| 455 |
BIO *ossl_cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm, |
| 456 |
const CMS_CTX *ctx); |
| 457 |
int ossl_cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain, |
| 458 |
X509_ALGOR *mdalg); |
| 459 |
|
| 460 |
int ossl_cms_ias_cert_cmp(CMS_IssuerAndSerialNumber *ias, X509 *cert); |
| 461 |
int ossl_cms_keyid_cert_cmp(ASN1_OCTET_STRING *keyid, X509 *cert); |
| 462 |
int ossl_cms_set1_ias(CMS_IssuerAndSerialNumber **pias, X509 *cert); |
| 463 |
int ossl_cms_set1_keyid(ASN1_OCTET_STRING **pkeyid, X509 *cert); |
| 464 |
|
| 465 |
BIO *ossl_cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec, |
| 466 |
const CMS_CTX *ctx, int auth); |
| 467 |
BIO *ossl_cms_EncryptedData_init_bio(const CMS_ContentInfo *cms); |
| 468 |
int ossl_cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec, |
| 469 |
const EVP_CIPHER *cipher, |
| 470 |
const unsigned char *key, size_t keylen, |
| 471 |
const CMS_CTX *ctx); |
| 472 |
|
| 473 |
int ossl_cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms); |
| 474 |
int ossl_cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src); |
| 475 |
ASN1_OCTET_STRING *ossl_cms_encode_Receipt(CMS_SignerInfo *si); |
| 476 |
|
| 477 |
BIO *ossl_cms_EnvelopedData_init_bio(CMS_ContentInfo *cms); |
| 478 |
int ossl_cms_EnvelopedData_final(CMS_ContentInfo *cms, BIO *chain); |
| 479 |
BIO *ossl_cms_AuthEnvelopedData_init_bio(CMS_ContentInfo *cms); |
| 480 |
int ossl_cms_AuthEnvelopedData_final(CMS_ContentInfo *cms, BIO *cmsbio); |
| 481 |
CMS_EnvelopedData *ossl_cms_get0_enveloped(CMS_ContentInfo *cms); |
| 482 |
CMS_AuthEnvelopedData *ossl_cms_get0_auth_enveloped(CMS_ContentInfo *cms); |
| 483 |
CMS_EncryptedContentInfo *ossl_cms_get0_env_enc_content(const CMS_ContentInfo *cms); |
| 484 |
|
| 485 |
/* RecipientInfo routines */ |
| 486 |
int ossl_cms_env_asn1_ctrl(CMS_RecipientInfo *ri, int cmd); |
| 487 |
int ossl_cms_pkey_get_ri_type(EVP_PKEY *pk); |
| 488 |
int ossl_cms_pkey_is_ri_type_supported(EVP_PKEY *pk, int ri_type); |
| 489 |
|
| 490 |
void ossl_cms_RecipientInfos_set_cmsctx(CMS_ContentInfo *cms); |
| 491 |
int ossl_cms_RecipientInfo_wrap_init(CMS_RecipientInfo *ri, const EVP_CIPHER *cipher); |
| 492 |
|
| 493 |
/* KARI routines */ |
| 494 |
int ossl_cms_RecipientInfo_kari_init(CMS_RecipientInfo *ri, X509 *recip, |
| 495 |
EVP_PKEY *recipPubKey, X509 *originator, |
| 496 |
EVP_PKEY *originatorPrivKey, |
| 497 |
unsigned int flags, |
| 498 |
const CMS_CTX *ctx); |
| 499 |
int ossl_cms_RecipientInfo_kari_encrypt(const CMS_ContentInfo *cms, |
| 500 |
CMS_RecipientInfo *ri); |
| 501 |
|
| 502 |
/* KEMRI routines */ |
| 503 |
int ossl_cms_RecipientInfo_kemri_get0_alg(CMS_RecipientInfo *ri, |
| 504 |
uint32_t **pkekLength, |
| 505 |
X509_ALGOR **pwrap); |
| 506 |
int ossl_cms_RecipientInfo_kemri_init(CMS_RecipientInfo *ri, X509 *recip, |
| 507 |
EVP_PKEY *recipPubKey, unsigned int flags, |
| 508 |
const CMS_CTX *ctx); |
| 509 |
int ossl_cms_RecipientInfo_kemri_encrypt(const CMS_ContentInfo *cms, |
| 510 |
CMS_RecipientInfo *ri); |
| 511 |
int ossl_cms_RecipientInfo_kemri_decrypt(const CMS_ContentInfo *cms, |
| 512 |
CMS_RecipientInfo *ri); |
| 513 |
int CMS_CMSORIforKEMOtherInfo_encode(unsigned char **pder, X509_ALGOR *wrap, |
| 514 |
ASN1_OCTET_STRING *ukm, int keylen); |
| 515 |
|
| 516 |
/* PWRI routines */ |
| 517 |
int ossl_cms_RecipientInfo_pwri_crypt(const CMS_ContentInfo *cms, |
| 518 |
CMS_RecipientInfo *ri, int en_de); |
| 519 |
/* SignerInfo routines */ |
| 520 |
int ossl_cms_si_check_attributes(const CMS_SignerInfo *si); |
| 521 |
void ossl_cms_SignerInfos_set_cmsctx(CMS_ContentInfo *cms); |
| 522 |
|
| 523 |
/* ESS routines */ |
| 524 |
int ossl_cms_check_signing_certs(const CMS_SignerInfo *si, |
| 525 |
const STACK_OF(X509) *chain); |
| 526 |
|
| 527 |
int ossl_cms_dh_envelope(CMS_RecipientInfo *ri, int decrypt); |
| 528 |
int ossl_cms_ecdh_envelope(CMS_RecipientInfo *ri, int decrypt); |
| 529 |
int ossl_cms_rsa_envelope(CMS_RecipientInfo *ri, int decrypt); |
| 530 |
int ossl_cms_rsa_sign(CMS_SignerInfo *si, int verify); |
| 531 |
int ossl_cms_kem_envelope(CMS_RecipientInfo *ri, int decrypt); |
| 532 |
|
| 533 |
int ossl_cms_get1_certs_ex(CMS_ContentInfo *cms, STACK_OF(X509) **certs); |
| 534 |
int ossl_cms_get1_crls_ex(CMS_ContentInfo *cms, STACK_OF(X509_CRL) **crls); |
| 535 |
|
| 536 |
DECLARE_ASN1_ITEM(CMS_CertificateChoices) |
| 537 |
DECLARE_ASN1_ITEM(CMS_DigestedData) |
| 538 |
DECLARE_ASN1_ITEM(CMS_EncryptedData) |
| 539 |
DECLARE_ASN1_ITEM(CMS_EnvelopedData) |
| 540 |
DECLARE_ASN1_ITEM(CMS_AuthEnvelopedData) |
| 541 |
DECLARE_ASN1_ITEM(CMS_KEKRecipientInfo) |
| 542 |
DECLARE_ASN1_ITEM(CMS_KEMRecipientInfo) |
| 543 |
DECLARE_ASN1_ITEM(CMS_KeyAgreeRecipientInfo) |
| 544 |
DECLARE_ASN1_ITEM(CMS_KeyTransRecipientInfo) |
| 545 |
DECLARE_ASN1_ITEM(CMS_OriginatorPublicKey) |
| 546 |
DECLARE_ASN1_ITEM(CMS_OtherKeyAttribute) |
| 547 |
DECLARE_ASN1_ITEM(CMS_OtherRecipientInfo) |
| 548 |
DECLARE_ASN1_ITEM(CMS_Receipt) |
| 549 |
DECLARE_ASN1_ITEM(CMS_ReceiptRequest) |
| 550 |
DECLARE_ASN1_ITEM(CMS_RecipientEncryptedKey) |
| 551 |
DECLARE_ASN1_ITEM(CMS_RecipientKeyIdentifier) |
| 552 |
DECLARE_ASN1_ITEM(CMS_RevocationInfoChoice) |
| 553 |
DECLARE_ASN1_ITEM(CMS_SignedData) |
| 554 |
DECLARE_ASN1_ITEM(CMS_CompressedData) |
| 555 |
|
| 556 |
#endif |