commit
ae1097d6ed
|
@ -128,6 +128,37 @@ static int Verify(byte* smime, int smimeSz, byte* ca, int caSz, byte* contentIn,
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* print out the signing time attribute if found */
|
||||||
|
if (ret == 0) {
|
||||||
|
word32 outSz;
|
||||||
|
byte* out;
|
||||||
|
int err;
|
||||||
|
const byte signingTimeOid[] = {
|
||||||
|
0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x05
|
||||||
|
};
|
||||||
|
|
||||||
|
err = wc_PKCS7_GetAttributeValue(&pkcs7Compat->pkcs7, signingTimeOid,
|
||||||
|
sizeof(signingTimeOid), NULL, &outSz);
|
||||||
|
if (err == LENGTH_ONLY_E) {
|
||||||
|
out = (byte*)XMALLOC(outSz + 1, NULL, DYNAMIC_TYPE_PKCS7);
|
||||||
|
if (out != NULL) {
|
||||||
|
err = wc_PKCS7_GetAttributeValue(&pkcs7Compat->pkcs7,
|
||||||
|
signingTimeOid, sizeof(signingTimeOid), out, &outSz);
|
||||||
|
if (err > 0) {
|
||||||
|
word32 i;
|
||||||
|
printf("Signing time attribute is :\n\t");
|
||||||
|
for (i = 0; i < outSz; i++)
|
||||||
|
printf("%02X", out[i]);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XFREE(out, NULL, DYNAMIC_TYPE_PKCS7);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("No signing time attribute found\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wolfSSL_BIO_free(in);
|
wolfSSL_BIO_free(in);
|
||||||
wolfSSL_BIO_free(content);
|
wolfSSL_BIO_free(content);
|
||||||
wolfSSL_BIO_free(multi);
|
wolfSSL_BIO_free(multi);
|
||||||
|
@ -145,6 +176,7 @@ static int ReadSmimeAndCert(char* smimeFile, char* certFile, char* contentFile,
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
XFILE f;
|
XFILE f;
|
||||||
|
*contentSz = 0;
|
||||||
|
|
||||||
f = XFOPEN(smimeFile, "rb");
|
f = XFOPEN(smimeFile, "rb");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
|
@ -188,6 +220,7 @@ static int ReadSmimeAndCert(char* smimeFile, char* certFile, char* contentFile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (contentFile != NULL) {
|
||||||
f = XFOPEN(contentFile, "rb");
|
f = XFOPEN(contentFile, "rb");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
printf("Error opening file %s\n", contentFile);
|
printf("Error opening file %s\n", contentFile);
|
||||||
|
@ -208,6 +241,7 @@ static int ReadSmimeAndCert(char* smimeFile, char* certFile, char* contentFile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -225,8 +259,9 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (argc != 4) {
|
if (argc < 3) {
|
||||||
printf("Use ./smime-verify <smime file> <der cert file> <content file>\n");
|
printf("Use ./smime-verify <smime file> <der cert file> "
|
||||||
|
"<optional content file>\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,8 +274,14 @@ int main(int argc, char** argv)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argc > 3) {
|
||||||
ret = ReadSmimeAndCert(argv[1], argv[2], argv[3], smime, &smimeSz, cert,
|
ret = ReadSmimeAndCert(argv[1], argv[2], argv[3], smime, &smimeSz, cert,
|
||||||
&certSz, content, &contentSz);
|
&certSz, content, &contentSz);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret = ReadSmimeAndCert(argv[1], argv[2], NULL, smime, &smimeSz, cert,
|
||||||
|
&certSz, content, &contentSz);
|
||||||
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = Verify(smime, smimeSz, cert, certSz, content, contentSz, 0);
|
ret = Verify(smime, smimeSz, cert, certSz, content, contentSz, 0);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
|
Loading…
Reference in New Issue