--- /dev/null
+#
+# To run the demos when linked with a shared library (default) ensure that
+# libcrypto is on the library path. For example, to run the
+# cms_enc demo:
+#
+# LD_LIBRARY_PATH=../.. ./cms_enc
+
+TESTS = cms_comp \
+ cms_ddec \
+ cms_dec \
+ cms_denc \
+ cms_enc \
+ cms_sign \
+ cms_sign2 \
+ cms_uncomp \
+ cms_ver
+
+CFLAGS = -I../../include -g
+LDFLAGS = -L../..
+LDLIBS = -lcrypto
+
+all: $(TESTS)
+
+clean:
+ $(RM) $(TESTS) *.o
+
+cms_%: cms_%.c
+ $(CC) $(CFLAGS) $(LDFLAGS) -o "$@" "$<" $(LDLIBS)
+
+test: all
+ @echo "\nCMS tests:"
+ LD_LIBRARY_PATH=../.. ./cms_enc
+ LD_LIBRARY_PATH=../.. ./cms_dec
+ LD_LIBRARY_PATH=../.. ./cms_sign2
+ LD_LIBRARY_PATH=../.. ./cms_ver
#include <openssl/cms.h>
#include <openssl/err.h>
+/*
+ * print any signingTime attributes.
+ * signingTime is when each party purportedly signed the message.
+ */
+static void print_signingTime(CMS_ContentInfo *cms)
+{
+ STACK_OF(CMS_SignerInfo) *sis;
+ CMS_SignerInfo *si;
+ X509_ATTRIBUTE *attr;
+ ASN1_TYPE *t;
+ ASN1_UTCTIME *utctime;
+ ASN1_GENERALIZEDTIME *gtime;
+ BIO *b;
+ int i, loc;
+
+ b = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT);
+ sis = CMS_get0_SignerInfos(cms);
+ for (i = 0; i < sk_CMS_SignerInfo_num(sis); i++) {
+ si = sk_CMS_SignerInfo_value(sis, i);
+ loc = CMS_signed_get_attr_by_NID(si, NID_pkcs9_signingTime, -1);
+ attr = CMS_signed_get_attr(si, loc);
+ t = X509_ATTRIBUTE_get0_type(attr, 0);
+ if (t == NULL)
+ continue;
+ switch (t->type) {
+ case V_ASN1_UTCTIME:
+ utctime = t->value.utctime;
+ ASN1_UTCTIME_print(b, utctime);
+ break;
+ case V_ASN1_GENERALIZEDTIME:
+ gtime = t->value.generalizedtime;
+ ASN1_GENERALIZEDTIME_print(b, gtime);
+ break;
+ default:
+ fprintf(stderr, "unrecognized signingTime type\n");
+ break;
+ }
+ BIO_printf(b, ": signingTime from SignerInfo %i\n", i);
+ }
+ BIO_free(b);
+ return;
+}
+
int main(int argc, char **argv)
{
BIO *in = NULL, *out = NULL, *tbio = NULL, *cont = NULL;
if (cms == NULL)
goto err;
+ print_signingTime(cms);
+
/* File to output verified content to */
out = BIO_new_file("smver.txt", "w");
if (out == NULL)
goto err;
}
- fprintf(stderr, "Verification Successful\n");
+ printf("Verification Successful\n");
ret = EXIT_SUCCESS;
+
err:
if (ret != EXIT_SUCCESS) {
fprintf(stderr, "Error Verifying Data\n");