summaryrefslogtreecommitdiffstats
path: root/crypto/pkcs7/pk7_attr.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2006-05-18 17:20:23 +0000
committerDr. Stephen Henson <steve@openssl.org>2006-05-18 17:20:23 +0000
commit76fa8f1838ae22948d760012d6c6c84266cb1c7c (patch)
treecd9b3a9055db115a895363c45485179760c7e06e /crypto/pkcs7/pk7_attr.c
parentf2b139ed1fc3541bb17a066bba5c12b30fa989fa (diff)
More S/MIME tidy. Place some common attribute operations in utility
functions.
Diffstat (limited to 'crypto/pkcs7/pk7_attr.c')
-rw-r--r--crypto/pkcs7/pk7_attr.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/crypto/pkcs7/pk7_attr.c b/crypto/pkcs7/pk7_attr.c
index 735c8800e1..5ad6670a4e 100644
--- a/crypto/pkcs7/pk7_attr.c
+++ b/crypto/pkcs7/pk7_attr.c
@@ -139,3 +139,42 @@ int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg)
sk_X509_ALGOR_push (sk, alg);
return 1;
}
+
+int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid)
+ {
+ if (PKCS7_get_signed_attribute(si, NID_pkcs9_contentType))
+ return 0;
+ if (!coid)
+ coid = OBJ_nid2obj(NID_pkcs7_data);
+ return PKCS7_add_signed_attribute(si, NID_pkcs9_contentType,
+ V_ASN1_OBJECT, coid);
+ }
+
+int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t)
+ {
+ if (!t && !(t=X509_gmtime_adj(NULL,0)))
+ {
+ PKCS7err(PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME,
+ ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
+ return PKCS7_add_signed_attribute(si, NID_pkcs9_signingTime,
+ V_ASN1_UTCTIME, t);
+ }
+
+int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,
+ const unsigned char *md, int mdlen)
+ {
+ ASN1_OCTET_STRING *os;
+ os = ASN1_OCTET_STRING_new();
+ if (!os)
+ return 0;
+ if (!ASN1_STRING_set(os, md, mdlen)
+ || PKCS7_add_signed_attribute(si, NID_pkcs9_messageDigest,
+ V_ASN1_OCTET_STRING, os))
+ {
+ ASN1_OCTET_STRING_free(os);
+ return 0;
+ }
+ return 1;
+ }