Home | History | Annotate | Line # | Download | only in man3
      1      1.1  christos =pod
      2      1.1  christos 
      3      1.1  christos =head1 NAME
      4      1.1  christos 
      5      1.1  christos CMS_get0_RecipientInfos, CMS_RecipientInfo_type,
      6      1.1  christos CMS_RecipientInfo_ktri_get0_signer_id, CMS_RecipientInfo_ktri_cert_cmp,
      7      1.1  christos CMS_RecipientInfo_set0_pkey, CMS_RecipientInfo_kekri_get0_id,
      8  1.1.1.2  christos CMS_RecipientInfo_kari_set0_pkey_and_peer,
      9  1.1.1.2  christos CMS_RecipientInfo_kari_set0_pkey,
     10      1.1  christos CMS_RecipientInfo_kekri_id_cmp, CMS_RecipientInfo_set0_key,
     11      1.1  christos CMS_RecipientInfo_decrypt, CMS_RecipientInfo_encrypt
     12      1.1  christos - CMS envelopedData RecipientInfo routines
     13      1.1  christos 
     14      1.1  christos =head1 SYNOPSIS
     15      1.1  christos 
     16      1.1  christos  #include <openssl/cms.h>
     17      1.1  christos 
     18      1.1  christos  STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms);
     19      1.1  christos  int CMS_RecipientInfo_type(CMS_RecipientInfo *ri);
     20      1.1  christos 
     21      1.1  christos  int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,
     22      1.1  christos                                            ASN1_OCTET_STRING **keyid,
     23      1.1  christos                                            X509_NAME **issuer,
     24      1.1  christos                                            ASN1_INTEGER **sno);
     25      1.1  christos  int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert);
     26      1.1  christos  int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);
     27  1.1.1.2  christos  int CMS_RecipientInfo_kari_set0_pkey_and_peer(CMS_RecipientInfo *ri,
     28  1.1.1.2  christos                                                EVP_PKEY *pk, X509 *peer);
     29  1.1.1.2  christos  int CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk);
     30      1.1  christos  int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri, X509_ALGOR **palg,
     31      1.1  christos                                      ASN1_OCTET_STRING **pid,
     32      1.1  christos                                      ASN1_GENERALIZEDTIME **pdate,
     33      1.1  christos                                      ASN1_OBJECT **potherid,
     34      1.1  christos                                      ASN1_TYPE **pothertype);
     35      1.1  christos  int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,
     36      1.1  christos                                     const unsigned char *id, size_t idlen);
     37      1.1  christos  int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri,
     38      1.1  christos                                 unsigned char *key, size_t keylen);
     39      1.1  christos 
     40      1.1  christos  int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);
     41      1.1  christos  int CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);
     42      1.1  christos 
     43      1.1  christos =head1 DESCRIPTION
     44      1.1  christos 
     45      1.1  christos The function CMS_get0_RecipientInfos() returns all the CMS_RecipientInfo
     46      1.1  christos structures associated with a CMS EnvelopedData structure.
     47      1.1  christos 
     48      1.1  christos CMS_RecipientInfo_type() returns the type of CMS_RecipientInfo structure B<ri>.
     49      1.1  christos It will currently return CMS_RECIPINFO_TRANS, CMS_RECIPINFO_AGREE,
     50      1.1  christos CMS_RECIPINFO_KEK, CMS_RECIPINFO_PASS, or CMS_RECIPINFO_OTHER.
     51      1.1  christos 
     52      1.1  christos CMS_RecipientInfo_ktri_get0_signer_id() retrieves the certificate recipient
     53      1.1  christos identifier associated with a specific CMS_RecipientInfo structure B<ri>, which
     54      1.1  christos must be of type CMS_RECIPINFO_TRANS. Either the keyidentifier will be set in
     55      1.1  christos B<keyid> or B<both> issuer name and serial number in B<issuer> and B<sno>.
     56      1.1  christos 
     57      1.1  christos CMS_RecipientInfo_ktri_cert_cmp() compares the certificate B<cert> against the
     58      1.1  christos CMS_RecipientInfo structure B<ri>, which must be of type CMS_RECIPINFO_TRANS.
     59      1.1  christos It returns zero if the comparison is successful and non zero if not.
     60      1.1  christos 
     61      1.1  christos CMS_RecipientInfo_set0_pkey() associates the private key B<pkey> with
     62      1.1  christos the CMS_RecipientInfo structure B<ri>, which must be of type
     63      1.1  christos CMS_RECIPINFO_TRANS.
     64      1.1  christos 
     65  1.1.1.2  christos CMS_RecipientInfo_kari_set0_pkey_and_peer() associates the private key B<pkey>
     66  1.1.1.2  christos and peer certificate B<peer> with the CMS_RecipientInfo structure B<ri>, which
     67  1.1.1.2  christos must be of type CMS_RECIPINFO_AGREE.
     68  1.1.1.2  christos 
     69  1.1.1.2  christos CMS_RecipientInfo_kari_set0_pkey() associates the private key B<pkey> with the
     70  1.1.1.2  christos CMS_RecipientInfo structure B<ri>, which must be of type CMS_RECIPINFO_AGREE.
     71  1.1.1.2  christos 
     72      1.1  christos CMS_RecipientInfo_kekri_get0_id() retrieves the key information from the
     73      1.1  christos CMS_RecipientInfo structure B<ri> which must be of type CMS_RECIPINFO_KEK.  Any
     74      1.1  christos of the remaining parameters can be NULL if the application is not interested in
     75      1.1  christos the value of a field. Where a field is optional and absent NULL will be written
     76      1.1  christos to the corresponding parameter. The keyEncryptionAlgorithm field is written to
     77      1.1  christos B<palg>, the B<keyIdentifier> field is written to B<pid>, the B<date> field if
     78      1.1  christos present is written to B<pdate>, if the B<other> field is present the components
     79      1.1  christos B<keyAttrId> and B<keyAttr> are written to parameters B<potherid> and
     80      1.1  christos B<pothertype>.
     81      1.1  christos 
     82      1.1  christos CMS_RecipientInfo_kekri_id_cmp() compares the ID in the B<id> and B<idlen>
     83      1.1  christos parameters against the B<keyIdentifier> CMS_RecipientInfo structure B<ri>,
     84      1.1  christos which must be of type CMS_RECIPINFO_KEK.  It returns zero if the comparison is
     85      1.1  christos successful and non zero if not.
     86      1.1  christos 
     87      1.1  christos CMS_RecipientInfo_set0_key() associates the symmetric key B<key> of length
     88      1.1  christos B<keylen> with the CMS_RecipientInfo structure B<ri>, which must be of type
     89      1.1  christos CMS_RECIPINFO_KEK.
     90      1.1  christos 
     91      1.1  christos CMS_RecipientInfo_decrypt() attempts to decrypt CMS_RecipientInfo structure
     92      1.1  christos B<ri> in structure B<cms>. A key must have been associated with the structure
     93      1.1  christos first.
     94      1.1  christos 
     95      1.1  christos CMS_RecipientInfo_encrypt() attempts to encrypt CMS_RecipientInfo structure
     96      1.1  christos B<ri> in structure B<cms>. A key must have been associated with the structure
     97      1.1  christos first and the content encryption key must be available: for example by a
     98      1.1  christos previous call to CMS_RecipientInfo_decrypt().
     99      1.1  christos 
    100      1.1  christos =head1 NOTES
    101      1.1  christos 
    102      1.1  christos The main purpose of these functions is to enable an application to lookup
    103      1.1  christos recipient keys using any appropriate technique when the simpler method
    104      1.1  christos of CMS_decrypt() is not appropriate.
    105      1.1  christos 
    106      1.1  christos In typical usage and application will retrieve all CMS_RecipientInfo structures
    107      1.1  christos using CMS_get0_RecipientInfos() and check the type of each using
    108      1.1  christos CMS_RecipientInfo_type(). Depending on the type the CMS_RecipientInfo structure
    109      1.1  christos can be ignored or its key identifier data retrieved using an appropriate
    110      1.1  christos function. Then if the corresponding secret or private key can be obtained by
    111      1.1  christos any appropriate means it can then associated with the structure and
    112      1.1  christos CMS_RecipientInfo_decrypt() called. If successful CMS_decrypt() can be called
    113      1.1  christos with a NULL key to decrypt the enveloped content.
    114      1.1  christos 
    115      1.1  christos The CMS_RecipientInfo_encrypt() can be used to add a new recipient to an
    116      1.1  christos existing enveloped data structure. Typically an application will first decrypt
    117      1.1  christos an appropriate CMS_RecipientInfo structure to make the content encrypt key
    118      1.1  christos available, it will then add a new recipient using a function such as
    119      1.1  christos CMS_add1_recipient_cert() and finally encrypt the content encryption key
    120      1.1  christos using CMS_RecipientInfo_encrypt().
    121      1.1  christos 
    122      1.1  christos =head1 RETURN VALUES
    123      1.1  christos 
    124      1.1  christos CMS_get0_RecipientInfos() returns all CMS_RecipientInfo structures, or NULL if
    125      1.1  christos an error occurs.
    126      1.1  christos 
    127      1.1  christos CMS_RecipientInfo_ktri_get0_signer_id(), CMS_RecipientInfo_set0_pkey(),
    128      1.1  christos CMS_RecipientInfo_kekri_get0_id(), CMS_RecipientInfo_set0_key() and
    129      1.1  christos CMS_RecipientInfo_decrypt() return 1 for success or 0 if an error occurs.
    130      1.1  christos CMS_RecipientInfo_encrypt() return 1 for success or 0 if an error occurs.
    131      1.1  christos 
    132      1.1  christos CMS_RecipientInfo_ktri_cert_cmp() and CMS_RecipientInfo_kekri_cmp() return 0
    133      1.1  christos for a successful comparison and non zero otherwise.
    134      1.1  christos 
    135      1.1  christos Any error can be obtained from L<ERR_get_error(3)>.
    136      1.1  christos 
    137      1.1  christos =head1 SEE ALSO
    138      1.1  christos 
    139      1.1  christos L<ERR_get_error(3)>, L<CMS_decrypt(3)>
    140      1.1  christos 
    141  1.1.1.2  christos =head1 HISTORY
    142  1.1.1.2  christos 
    143  1.1.1.2  christos B<CMS_RecipientInfo_kari_set0_pkey_and_peer> and B<CMS_RecipientInfo_kari_set0_pkey>
    144  1.1.1.2  christos were added in OpenSSL 3.0.
    145  1.1.1.2  christos 
    146      1.1  christos =head1 COPYRIGHT
    147      1.1  christos 
    148  1.1.1.2  christos Copyright 2008-2021 The OpenSSL Project Authors. All Rights Reserved.
    149      1.1  christos 
    150  1.1.1.2  christos Licensed under the Apache License 2.0 (the "License").  You may not use
    151      1.1  christos this file except in compliance with the License.  You can obtain a copy
    152      1.1  christos in the file LICENSE in the source distribution or at
    153      1.1  christos L<https://www.openssl.org/source/license.html>.
    154      1.1  christos 
    155      1.1  christos =cut
    156