x400_mssend_rcv_sign.c
1/* Copyright (c) 2014-2025, Isode Limited, London, England.
2 * All rights reserved.
3 *
4 * Acquisition and use of this software and related materials for any
5 * purpose requires a written licence agreement from Isode Limited,
6 * or a written licence from an organisation licenced by Isode Limited
7 * to grant such a licence.
8 *
9 */
10
11/*
12 *
13 * 15.0a0-0
14 * Simple example program for submitting a message via a message store.
15 * The security environment is set up so that messages are signed.
16 */
17
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21
22#include <x400_msapi.h>
23#include <seclabel_api.h> /* For security labels */
24#include <errno.h>
25
26#include "example.h"
27
28static char *optstr = "u37m:d:p:w:M:D:P:W:r:o:O:r:g:G:c:l:R:y:C:iaqsAve:x:b:f:S:Y:Z4U:L:";
29
30/* These are the data items used to construct the message for submission */
31static char *default_recip = "/CN=lppt1/OU=lppt/O=attlee/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
32char *recip;
33static char *content_id = "030924.140212";
34static const char text[] = "First line\r\nSecond line\r\n";
35static char *binary_data;
36
37const char* xml_filename = "seclabel.xml";
38
39static int setup_msg_sec_env = 0;
40
41int num_unsigned_rcvd;
42int num_unverified_rcvd;
43int num_verified_rcvd;
44
45/* local functions */
46
47static void usage(void) ;
48static int send_msg(
49 int contype,
50 char *orn,
51 char *def_dn,
52 char *pa,
53 char *password);
54
55static int submit_msg(
56 char *orn,
57 struct X400msSession *sp /* session object */
58);
59
60static int get_msg(
61 struct X400msSession *sp
62);
63
64static int setup_default_new_sec_env(
65 struct X400msSession *sp,
66 char *identity_filename,
67 char *pw
68);
69
70static int setup_default_old_sec_env(
71 struct X400msSession *sp,
72 char *id,
73 char *dn,
74 char *pw
75);
76
77static int setup_msg_new_sec_env(
78 struct X400msMessage *mp, /* message object */
79 char *identity_filename,
80 char *pw
81);
82
83static int add_x411_label(
84 struct X400msMessage *mp, /* message object */
85 const char* xml_filename
86);
87
88static int add_4066_label(
89 struct X400msMessage *mp, /* message object */
90 const char* xml_filename
91);
92
93static int setup_msg_old_sec_env(
94 struct X400msMessage *mp, /* message object */
95 char *id,
96 char *dn,
97 char *pw
98);
99
100static int report_moac_info(
101 struct X400msMessage *mp
102);
103
104static void show_4406_certificate (struct X400msMessage *mp);
105static void show_certificate (struct X400msMessage *mp);
106static int report_4406_info(
107 struct X400msMessage *mp
108);
109
110static void print_sec_label(
111 char slab_buffer[],
112 unsigned int length
113);
114
115/* start here */
116int main (
117 int argc,
118 char **argv
119)
120{
121 char pa[BUFSIZ];
122 char orn[BUFSIZ];
123 char *def_oraddr;
124 char *def_dn;
125 char *def_pa;
126 int contype;
127 int status;
128 char password[BUFSIZ];
129
130 if (get_args(argc, argv, optstr)) {
131 usage();
132 exit(-1);
133 }
134
135 printf("Connection type (0 = P7, 1 = P3 submit only, 2 = P3 both directions) [%d]: ", x400_contype);
136 contype = ic_fgetc(x400_contype, stdin);
137 if (contype != 10)
138 ic_fgetc(x400_contype, stdin);
139
140 if ( contype < '0' || '2' < contype )
141 contype = x400_contype;
142 else
143 contype -= '0';
144
145 if (contype == 0) {
146 def_oraddr = x400_ms_user_addr;
147 def_dn = x400_ms_user_dn;
148 def_pa = x400_ms_presentation_address;
149 } else {
150 def_oraddr = x400_mta_user_addr;
151 def_dn = x400_mta_user_dn;
152 def_pa = x400_mta_presentation_address;
153 }
154
155 printf("Your ORAddress [%s] > ", def_oraddr);
156 ic_fgets (orn, sizeof orn, stdin);
157
158 if ( orn[strlen(orn)-1] == '\n' )
159 orn[strlen(orn)-1] = '\0';
160
161 if (orn[0] == '\0')
162 strcpy(orn, def_oraddr);
163
164 /* Prompt for password; note: reflected. */
165 printf ("Password [%s]: ",
166 contype == 0 ? x400_p7_password : x400_p3_password);
167 if ( ic_fgets (password, sizeof password, stdin) == NULL )
168 exit (1);
169
170 if (password[strlen(password)-1] == '\n' )
171 password[strlen(password)-1] = '\0';
172 if (password[0] == '\0')
173 strcpy(password, contype == 0 ? x400_p7_password : x400_p3_password);
174
175 /* Presentation Address */
176 printf("Presentation Address [%s] > ", def_pa);
177 ic_fgets (pa, sizeof pa, stdin);
178
179 if ( pa[strlen(pa)-1] == '\n' )
180 pa[strlen(pa)-1] = '\0';
181
182 if (pa[0] == '\0')
183 strcpy(pa, def_pa);
184
185 printf("sending message using session 1\n");
186 if ((status = send_msg(contype, orn, def_dn, pa, password))
187 != X400_E_NOERROR ) {
188 fprintf (stderr, "Error in sending message\n");
189 exit (status);
190 }
191 printf("sending message using session 2\n");
192 if ((status = send_msg(contype, orn, def_dn, pa, password))
193 != X400_E_NOERROR ) {
194 fprintf (stderr, "Error sending message\n");
195 exit (status);
196 }
197 return (status);
198}
199
200static int send_msg(
201 int contype,
202 char *orn,
203 char *def_dn,
204 char *pa,
205 char *password
206)
207{
208 struct X400msSession *sp; /* session object */
209
210 int status;
211
212
213 /* we've got what we need - now open an API session */
214 status = X400msOpen (contype, orn, def_dn, password, pa, NULL, &sp);
215 if ( status != X400_E_NOERROR ) {
216 fprintf (stderr, "Error in Open: %s\n", X400msError (status));
217 fprintf (stderr, "%s %s %s\n", orn, def_dn, pa);
218 return (status);
219 }
220
221 /* setup logging */
223
224 /* Set up the security environment.
225 *
226 * The security env can be specified the new way (recommended) using
227 * a PKCS12 filename and passphrase, or as a directory (deprecated and
228 * obsolete).
229 *
230 * If the ID is specified as a directory, in which the subdirectory
231 * "x509" is expected to contain one or more PKCS12 files.
232 * The appropriate Digital Identity is determined from the
233 * DN of the subject, and the passphrase is used to decrypt
234 * the private key.
235 */
236 if (use_new_sec_env) {
237 status = setup_default_new_sec_env(sp, identity_filename, passphrase);
238 } else {
239 status = setup_default_old_sec_env(sp, security_id, identity_dn,
240 passphrase);
241 }
242
243 if ( status != X400_E_NOERROR ) {
244 fprintf (stderr, "Can't setup security environment\n");
245 return (status);
246 }
247
248 printf("sending message 1\n");
249 status = submit_msg(orn, sp);
250 if ( status != X400_E_NOERROR ) {
251 fprintf (stderr, "Can't submit\n");
252 return (status);
253 }
254
255 printf("sending message 2\n");
256 status = submit_msg(orn, sp);
257 if ( status != X400_E_NOERROR ) {
258 fprintf (stderr, "Can't submit\n");
259 return (status);
260 }
261
262 printf("sending message 3\n");
263 status = submit_msg(orn, sp);
264 if ( status != X400_E_NOERROR ) {
265 fprintf (stderr, "Can't submit\n");
266 return (status);
267 }
268
269 /* now get a message */
270 status = get_msg(sp);
271 if (status != X400_E_NOERROR) {
272 fprintf(stderr, "Error in getting msg: %s\n",
273 X400msError(status));
274 exit(status);
275 }
276
277 status = X400msClose (sp);
278 if ( status != X400_E_NOERROR ) {
279 fprintf (stderr, "X400msClose returned error: %s\n", X400msError (status));
280 return (status);
281 }
282 return status;
283}
284
285static int submit_msg(
286 char *orn,
287 struct X400msSession *sp /* session object */
288)
289{
290 struct X400msMessage *mp; /* message object */
291 struct X400Recipient *rp; /* recipient object */
292 char tmp[BUFSIZ];
293 FILE *fp = NULL;
294 int fs=0;
295 int status;
296
297 if (x400_default_recipient != NULL)
298 recip = x400_default_recipient;
299 else
300 recip = default_recip;
301
302 printf("Message recipient [%s]: ", recip);
303 ic_fgets (tmp, sizeof tmp, stdin);
304
305 if ( tmp[strlen(tmp)-1] == '\n' )
306 tmp[strlen(tmp)-1] = '\0';
307 if (strlen(tmp) != 0)
308 recip = strdup(tmp);
309
310 printf("Subject [%s]: ", subject);
311 ic_fgets (tmp, sizeof tmp, stdin);
312
313 if ( tmp[strlen(tmp)-1] == '\n' )
314 tmp[strlen(tmp)-1] = '\0';
315 if (strlen(tmp) != 0)
316 subject = strdup(tmp);
317
318 status = X400msMsgNew (sp, X400_MSG_MESSAGE, &mp);
319 if ( status != X400_E_NOERROR ) {
320 fprintf (stderr, "x400msMsgNew returned error: %s\n", X400msError (status));
321 return (status);
322 }
323
324 /* Set up the security environment for this message overriding the
325 * default security env.
326 *
327 * The security env can be specified the new way (recommended) using
328 * a PKCS12 filename and passphrase, or as a directory (deprecated and
329 * obsolete).
330 *
331 * If the ID is specified as a pathname, in which the subdirectory
332 * "x509" is expected to contain one or more PKCS12 files.
333 * The appropriate Digital Identity is determined from the
334 * DN of the subject, and the passphrase is used to decrypt
335 * the private key.
336 */
337 if (setup_msg_sec_env) {
338 if (use_new_sec_env) {
339 status = setup_msg_new_sec_env(mp, identity_filename, passphrase);
340 if ( status != X400_E_NOERROR ) {
341 fprintf (stderr, "Can't setup new security environment\n");
342 return (status);
343 }
344 } else {
345 status = setup_msg_old_sec_env(mp, security_id, identity_dn2,
346 passphrase);
347 if ( status != X400_E_NOERROR ) {
348 fprintf (stderr, "Can't setup old security environment\n");
349 return (status);
350 }
351 }
352 }
353
354 /* Instruct the X400msMsgSend() function to generate a MOAC (signature) for
355 * the message.
356 *
357 * The default attributes will be used unless the attributes are
358 * also included in the message eg by calling setup_msg_sec_env() above
359 */
360 if (gen_moac) {
362 if ( status != X400_E_NOERROR ) {
363 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n",
364 X400msError (status));
365 return (status);
366 }
367 }
368
369 /* Instruct the X400msMsgSend() function to generate a STANAG 4406
370 * signature for the message
371 *
372 * The default attributes will be used unless the attributes are
373 * also included in the message eg by calling setup_msg_sec_env() above
374 */
375 if (gen_4406_sig) {
376 printf("\nRequesting 4406 signature\n");
377 status = X400msMsgAddIntParam (mp, X400_N_S4406, 1);
378 if ( status != X400_E_NOERROR ) {
379 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n", X400msError (status));
380 return (status);
381 }
382
383 /* add a security label */
384 printf("\nAdding 4406 label\n");
385 status = add_4066_label (mp, xml_filename);
386 if ( status != X400_E_NOERROR ) {
387 fprintf (stderr, "add_4406_label returned error: %s\n",
388 X400msError (status));
389 return (status);
390 }
391
392 } else {
393 printf("\nNot requesting 4406 signature\n");
394 }
395
396 if (need_x411_label) {
397 status = add_x411_label (mp, xml_filename);
398 if ( status != X400_E_NOERROR ) {
399 fprintf (stderr, "add_x411_label returned error: %s\n",
400 X400msError (status));
401 return (status);
402 }
403 } else {
404 printf("\nNot requesting X.411 Label\n");
405 }
406
407 status = X400msRecipNew (mp, X400_RECIP_STANDARD, &rp);
408 if ( status != X400_E_NOERROR ) {
409 fprintf (stderr, "x400msRecipNew returned error: %s\n", X400msError (status));
410 return (status);
411 }
412
413 status = X400msRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip, -1);
414 if ( status != X400_E_NOERROR ) {
415 fprintf (stderr, "x400msRecipAddStrParam returned error: %s\n", X400msError (status));
416 return (status);
417 }
418
419 status = X400msRecipAddStrParam (rp, X400_S_DIRECTORY_NAME, "CN=recipient;c=gb", -1);
420 if ( status != X400_E_NOERROR ) {
421 fprintf (stderr, "x400msRecipAddStrParam returned error: %s\n", X400msError (status));
422 return (status);
423 }
424
425 status = X400msMsgAddStrParam (mp, X400_S_OR_ADDRESS, orn, -1);
426 if ( status != X400_E_NOERROR ) {
427 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n", X400msError (status));
428 return (status);
429 }
430
431 status = X400msMsgAddStrParam (mp, X400_S_DIRECTORY_NAME, "CN=originator;c=gb", -1);
432 if ( status != X400_E_NOERROR ) {
433 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n", X400msError (status));
434 return (status);
435 }
436
437 /* Ask for +ve and -ve delivery reports */
439 if ( status != X400_E_NOERROR ) {
440 fprintf (stderr, "x400msRecipAddStrParam returned error: %s\n", X400msError (status));
441 return (status);
442 }
443
444 /* Ask for +ve and -ve read receipts */
446 if ( status != X400_E_NOERROR ) {
447 fprintf (stderr, "x400msRecipAddStrParam returned error: %s\n", X400msError (status));
448 return (status);
449 }
450
452 content_id, -1);
453 if ( status != X400_E_NOERROR ) {
454 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n", X400msError (status));
455 return (status);
456 }
457
458 status = X400msMsgAddStrParam (mp, X400_S_SUBJECT, subject, -1);
459 if ( status != X400_E_NOERROR ) {
460 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n", X400msError (status));
461 return (status);
462 }
463
464 status = X400msMsgAddStrParam (mp, X400_T_ISO8859_1, text, -1);
465 if ( status != X400_E_NOERROR ) {
466 fprintf (stderr, "x400ms returned error: %s\n", X400msError (status));
467 return (status);
468 }
469
470 /* now an IA5 body part using the bodypart func */
471 status = X400msMsgAddAttachment (mp, X400_T_IA5TEXT, text, strlen(text));
472 if ( status != X400_E_NOERROR ) {
473 printf("failed to add X400_T_IA5TEXT BP\n");
474 return (status);
475 }
476
477 /* or a Binary body part using the bodypart func */
478 if (filename_to_send != NULL) {
479 binary_data = (char *) malloc(100000);
480 if ( binary_data == NULL )
481 return X400_E_NOMEMORY;
482 fp = fopen(filename_to_send, "r");
483 if (fp == (FILE *)NULL) {
484 printf("Cannot open binary file\n");
485 return (X400_E_SYSERROR);
486 }
487 if ((fs = fread (binary_data, sizeof(char), 100000/sizeof(char), fp) ) == -1) {
488 printf("Cannot read from binary file\n");
489 return (X400_E_SYSERROR);
490 }
491 fclose(fp);
492
493 status = X400msMsgAddAttachment (mp, X400_T_BINARY, binary_data, fs);
494 if ( status != X400_E_NOERROR ) {
495 printf("failed to add X400_T_BINARY BP\n");
496 return (status);
497 }
498 } else {
499 printf("no binary file set - not sending X400_T_BINARY\n");
500 }
501
502 status = X400msMsgSend (mp);
503 if ( status != X400_E_NOERROR ) {
504 fprintf (stderr, "x400msMsgSend returned error: %s\n", X400msError (status));
505 return (status);
506 } else {
507 printf("Message submitted successfully\n");
508 }
509
510 status = X400msMsgDelete (mp, 0);
511 if ( status != X400_E_NOERROR ) {
512 fprintf (stderr, "x400msMsgDelete returned error: %s\n", X400msError (status));
513 return (status);
514 }
515
516 mp = NULL;
517 rp = NULL;
518
519 return (status);
520}
521
522
523static int setup_default_new_sec_env(
524 struct X400msSession *sp,
525 char *identity,
526 char *pw
527)
528{
529 int status;
530
531 /* Filename of the Digital Identity (PKCS12 file) */
533 identity, -1);
534 if ( status != X400_E_NOERROR ) {
535 fprintf (stderr, "X400msSetStrDefault returned error: %s\n",
536 X400msError (status));
537 return (status);
538 }
539
540 /* passphrase used to open the Identity */
542 if ( status != X400_E_NOERROR ) {
543 fprintf (stderr, "X400msSetStrDefault returned error: %s\n",
544 X400msError (status));
545 return (status);
546 }
547
548 /* test the sec env */
549 status = X400msTestSecurityEnv (sp);
550 if ( status != X400_E_NOERROR ) {
551 fprintf (stderr, "X400msTestSecurityEnv returned error: %s\n",
552 X400msError (status));
553 return (status);
554 }
555
556 return status;
557}
558
559static int setup_default_old_sec_env(
560 struct X400msSession *sp,
561 char *id,
562 char *dn,
563 char *pw
564)
565{
566 int status;
567
568 /* first set a default security identity. This passes in the name of a
569 * directory, which contains an x509 subdirectory in which all Identities
570 * are held */
572
573 /* select by DN which Identity is to be used (if there are several)
574 * Currently these must be PKCS12 files */
575 status = X400msSetStrDefault (sp, X400_S_SEC_IDENTITY_DN, dn, -1);
576 if ( status != X400_E_NOERROR ) {
577 fprintf (stderr, "X400msSetStrDefault returned error: %s\n",
578 X400msError (status));
579 return (status);
580 }
581
582 /* passphrase used to open the Identity */
584 if ( status != X400_E_NOERROR ) {
585 fprintf (stderr, "X400msSetStrDefault returned error: %s\n",
586 X400msError (status));
587 return (status);
588 }
589
590 return status;
591}
592
593static int setup_msg_new_sec_env(
594 struct X400msMessage *mp, /* message object */
595 char *identity,
596 char *pw
597)
598{
599 int status;
600
601 /* Filename of the Digital Identity (PKCS12 file) */
603 identity, -1);
604 if ( status != X400_E_NOERROR ) {
605 fprintf (stderr, "X400msMsgAddStrParam returned error: %s\n",
606 X400msError (status));
607 return (status);
608 }
609
610 /* security additions */
612 if ( status != X400_E_NOERROR ) {
613 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n",
614 X400msError (status));
615 return (status);
616 }
617 return (status);
618}
619
620static int setup_msg_old_sec_env(
621 struct X400msMessage *mp, /* message object */
622 char *id,
623 char *dn,
624 char *pw
625)
626{
627 int status;
628
629 /* overide the default security environment by specifying a new set of
630 * attibutes, and put them into the message */
631 /* security additions */
632 status = X400msMsgAddStrParam (mp, X400_S_SEC_IDENTITY, id, -1);
633 /* status = X400msMsgAddStrParam (mp, X400_S_SEC_IDENTITY, "/var/isode/dsa-db", -1); */
634 if ( status != X400_E_NOERROR ) {
635 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n",
636 X400msError (status));
637 return (status);
638 }
639
640 /* security additions */
641 status = X400msMsgAddStrParam (mp, X400_S_SEC_IDENTITY_DN, dn, -1);
642 if ( status != X400_E_NOERROR ) {
643 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n",
644 X400msError (status));
645 return (status);
646 }
647
648 /* security additions */
650 if ( status != X400_E_NOERROR ) {
651 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n",
652 X400msError (status));
653 return (status);
654 }
655 return (status);
656}
657
658
659static int add_4066_label(
660 struct X400msMessage *mp, /* message object */
661 const char* filename
662)
663{
664
665#define XML_BUFSIZE 1024
666#define STRING_BUFSIZE 1024
667
668 int status;
669 char xml_content[XML_BUFSIZE];
670 char str_content[STRING_BUFSIZE];
671 int str_len = STRING_BUFSIZE;
672 FILE *fd = NULL;
673
674 printf("Adding 4406 Security Label, using file %s\n", filename);
675 /* Read in the security label XML file */
676 fd = fopen(filename,"r");
677 if(fd == NULL) {
678 fprintf(stderr,"Failed to open %s : %s\n",
679 filename,strerror(errno));
680 }
681
682#pragma GCC diagnostic push
683#pragma GCC diagnostic ignored "-Wunused-result"
684 fread(&xml_content,XML_BUFSIZE,1,fd);
685#pragma GCC diagnostic pop
686
687 fclose(fd);
688
689 status = SecLabelInit("Example program 2");
690 if (status != SECLABEL_E_NOERROR) {
691 fprintf(stderr, "SecLabelInit returned error %d\n", status);
692 return X400_E_INVALID_ATTR;
693 }
694
695 /* Use SecLabelParse to turn the XML into an octet string */
696 status = SecLabelParse(xml_content,
697 str_content,
698 STRING_BUFSIZE,
699 &str_len);
700
701 if (status != SECLABEL_E_NOERROR) {
702 fprintf(stderr, "SecLabelParse returned error %d\n", status);
703 return X400_E_INVALID_ATTR;
704 }
705
706 /* Add the octet string to the message pointer */
708 str_content,str_len);
709 if ( status != X400_E_NOERROR ) {
710 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n",
711 X400msError (status));
712 return (status);
713 }
714 return X400_E_NOERROR;
715
716}
717
718
719static int add_x411_label(
720 struct X400msMessage *mp, /* message object */
721 const char* filename
722)
723{
724
725#define XML_BUFSIZE 1024
726#define STRING_BUFSIZE 1024
727
728 int status;
729 char xml_content[XML_BUFSIZE];
730 char str_content[STRING_BUFSIZE];
731 int str_len = STRING_BUFSIZE;
732 FILE *fd = NULL;
733
734 printf("Adding X.411 Security Label, using file %s\n", filename);
735 /* Read in the security label XML file */
736 fd = fopen(filename,"r");
737 if(fd == NULL) {
738 fprintf(stderr,"Failed to open %s : %s\n",
739 filename,strerror(errno));
740 }
741
742#pragma GCC diagnostic push
743#pragma GCC diagnostic ignored "-Wunused-result"
744 fread(&xml_content,XML_BUFSIZE,1,fd);
745#pragma GCC diagnostic pop
746
747 fclose(fd);
748
749 status = SecLabelInit("Example program");
750 if (status != SECLABEL_E_NOERROR) {
751 fprintf(stderr, "SecLabelInit returned error %d\n", status);
752 return X400_E_INVALID_ATTR;
753 }
754
755 /* Use SecLabelParse to turn the XML into an octet string */
756 status = SecLabelParse(xml_content,
757 str_content,
758 STRING_BUFSIZE,
759 &str_len);
760
761 if (status != SECLABEL_E_NOERROR) {
762 fprintf(stderr, "SecLabelParse returned error %d\n", status);
763 return X400_E_INVALID_ATTR;
764 }
765
766 /* Add the octet string to the message pointer */
768 str_content,str_len);
769 if ( status != X400_E_NOERROR ) {
770 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n",
771 X400msError (status));
772 return (status);
773 }
774 return X400_E_NOERROR;
775
776}
777
778
779static int get_msg(
780 struct X400msSession *sp
781)
782{
783 char buffer[BUFSIZ];
784 int status;
785 int nummsg;
786 int type;
787 int seqn;
788 struct X400msMessage *mp;
789 struct X400Recipient *rp;
790 int n;
791 size_t length;
792 int intparam;
793 char recipient_str[BUFSIZ];
794
795 printf("Waiting for new messages for 10 seconds\n");
796 status = X400msWait(sp, 10, &nummsg);
797 if (status != X400_E_NOERROR) {
798 fprintf(stderr, "Error from Wait: %s\n", X400msError(status));
799 /* tidily close the session */
800 status = X400msClose(sp);
801 exit(status);
802 }
803
804 /* Set up the security environment.
805 *
806 * In R15.0 this need only be the name of a trusted certificate directory.
807 *
808 * Prior to R15.0, the ID is specified as a pathname, in which the
809 * subdirectory "x509" is expected to contain one or more PKCS12
810 * files. The appropriate Digital Identity is determined from the
811 * DN of the subject, and the passphrase is used to decrypt the
812 * private key. NB even though we're not going to use our cert,
813 * (as we're going to use the cert in the message to check the MOAC
814 * we need to do this due to a limitation in the underlying X.509
815 * layer.
816 */
817 /*
818 if (use_new_sec_env) {
819 setup_default_new_sec_env(sp, trusted_ca_certs_dir);
820 } else {
821 setup_default_old_sec_env(sp, security_id, identity_dn, passphrase);
822 }
823 */
824
825
826 /* Turn off legacy bahaviour in which MOAC verification failure
827 * returns X400_E_NOERROR.
828 * We will now get X400_E_X509_VERIFY_FAILURE from MsgGet
829 * if/when the verification fails
830 */
832
833 if (x400_default_recipient != NULL)
834 printf("Getting message\n");
835 status = X400msMsgGet(sp, 0, &mp, &type, &seqn);
836 switch (status) {
837 case X400_E_NOERROR:
838 fprintf(stderr, "MsgGet successfully got message\n");
839 break;
840 default :
841 fprintf(stderr, "Error from MsgGet: %s\n", X400msError(status));
842 /* tidily close the session */
843 status = X400msClose(sp);
844 exit(status);
845 break;
846 }
847
848 if (type != X400_MSG_MESSAGE) {
849 fprintf(stderr, "Got a report (printing only some attributes)\n");
850
851 /* The ORADDRESS in the message is the (envelope) originator */
853 buffer, sizeof buffer, &length);
854 if (status != X400_E_NOERROR) {
855 fprintf(stderr, "Error from MsgGetStrParam: %s\n",
856 X400msError(status));
857 /* tidily close the session */
858 status = X400msClose(sp);
859 exit(status);
860 }
861 printf("Subject Identifier: %.*s\n", (int)length, buffer);
862
863 /* Get the primary recipients */
864 for (n = 1;; n++) {
865 status = X400msRecipGet(mp, X400_RECIP_REPORT, n, &rp);
866 if (status == X400_E_NO_RECIP)
867 break;
868 if (status != X400_E_NOERROR) {
869 fprintf(stderr, "Error from RecipGet: %s\n",
870 X400msError(status));
871 /* tidily close the session */
872 status = X400msClose(sp);
873 exit(status);
874 }
875
876 /* Note: recipient may not actually have an O/R address */
878 recipient_str,
879 sizeof recipient_str, &length);
880 if (status != X400_E_NOERROR) {
881 fprintf(stderr, "Error from RecipGetStrParam: %s\n",
882 X400msError(status));
883 /* tidily close the session */
884 status = X400msClose(sp);
885 exit(status);
886 }
887 /* print out the O/R Address of the report */
888 printf("Positive Delivery Report for recipient %d: %.*s\n", n,
889 (int)length, recipient_str);
890
891 /* The original message delivery time, if this attribute exists,
892 * then the report is a positive Delivery Report */
894 buffer, sizeof buffer, &length);
895 if (status == X400_E_NOERROR) {
896 /* Positive Delivery Report */
897 printf("Delivery Time: %.*s\n", (int)length, buffer);
898 }
899 else {
900 /* Negative Delivery Report */
901 printf("Negative Delivery Report for recipient %d: %s\n", n,
902 recipient_str);
903
904 /* Supplementary Info to the report */
906 buffer, sizeof buffer,
907 &length);
908 if (status != X400_E_NOERROR) {
909 fprintf(stderr, "Error from RecipGetStrParam: %s\n",
910 X400msError(status));
911 buffer[0] = '\0';
912 }
913 printf("Supplementary Info: %.*s\n", (int)length, buffer);
914
915 /* The reason why the message was not delivered */
916 status =
918 &intparam);
919 if (status != X400_E_NOERROR) {
920 fprintf(stderr, "Error from MsgGetIntParam: %s\n",
921 X400msError(status));
922 }
923 printf("Non-Delivery Reason: %d\n", intparam);
924
925 /* The diagnostics of the report for this recipient */
926 status =
928 &intparam);
929 if (status != X400_E_NOERROR) {
930 fprintf(stderr, "Error from MsgGetIntParam: %s\n",
931 X400msError(status));
932 }
933 printf("Non-Delivery Diagnostic: %d\n", intparam);
934 }
935 }
936
937 num_unsigned_rcvd++ ;
938 status = X400msMsgDelete(mp, 0);
939 if (status != X400_E_NOERROR) {
940 fprintf(stderr, "Error from X400msMsgDelete: %s\n",
941 X400msError(status));
942 }
943 return (status);
944 }
945
946
947 /* x411 security label */
949 buffer, sizeof buffer, &length);
950 if (status == X400_E_NO_VALUE) {
951 printf("No X.411 security label\n");
952 } else if (status != X400_E_NOERROR) {
953 fprintf(stderr,"Failed to fetch X.411 security label: %d (%s)",
954 status, X400msError(status));
955 return (status);
956 } else {
957 fprintf(stderr, "X.411 Security Label returned OK (%d chars)\n",
958 (int)length);
959 print_sec_label(buffer, length);
960 }
961
962 /* report information about the MOAC in the message */
963 report_moac_info(mp);
964
965 /* report information about the 4406 in the message */
966 report_4406_info(mp);
967
968 /* The message identifier */
970 buffer, sizeof buffer, &length);
971 if (status != X400_E_NOERROR) {
972 fprintf(stderr, "Error from MsgGetStrParam: %s\n",
973 X400msError(status));
974 /* tidily close the session */
975 status = X400msClose(sp);
976 exit(status);
977 }
978 printf("Message Identifier: %.*s\n", (int)length, buffer);
979
980 /* The ORADDRESS in the message is the (envelope) originator */
982 buffer, sizeof buffer, &length);
983 if (status != X400_E_NOERROR) {
984 fprintf(stderr, "Error from MsgGetStrParam: %s\n",
985 X400msError(status));
986 /* tidily close the session */
987 status = X400msClose(sp);
988 exit(status);
989 }
990 printf("Originator: %.*s\n", (int)length, buffer);
991
992 /* Get the primary recipients */
993 for (n = 1;; n++) {
994 status = X400msRecipGet(mp, X400_RECIP_PRIMARY, n, &rp);
995 if (status == X400_E_NO_RECIP)
996 break;
997 if (status != X400_E_NOERROR) {
998 fprintf(stderr, "Error from RecipGet: %s\n", X400msError(status));
999 /* tidily close the session */
1000 status = X400msClose(sp);
1001 exit(status);
1002 }
1003
1004 /* Note: recipient may not actually have an O/R address */
1006 buffer, sizeof buffer, &length);
1007 if (status == X400_E_NOERROR) {
1008 printf("Recipient %d: %.*s\n", n, (int)length, buffer);
1009 }
1010 }
1011
1012 /* Subject is optional */
1014 buffer, sizeof buffer, &length);
1015 if (status == X400_E_NOERROR)
1016 printf("Subject: %.*s\n", (int)length, buffer);
1017
1018 /* And message text (or it could be another type) */
1020 buffer, sizeof buffer, &length);
1021 if (status == X400_E_NOERROR)
1022 printf("Text:\n%.*s\n", (int)length, buffer);
1023
1024 /* Deletes message in message store as well as internal copy */
1025 status = X400msMsgDelete(mp, 0);
1026
1027 return status;
1028}
1029
1030#ifdef notdef
1031/*
1032 * Recommended function to setup security env for verification.
1033 * No digitial ID required - just a directory which contains
1034 * trust anchors which are read as DER file (certificate.crt).
1035 *
1036 * The certificate (containing public key) is obtained from the message
1037 * which is referenced in the message.
1038 */
1039
1040static void setup_default_new_sec_env(
1041 struct X400msSession *sp,
1042 char *trusted_ca_certs_dir
1043)
1044{
1045 int status;
1046
1047 /* Directory containing trusted CA Certificates */
1048 printf(" Adding %s as trusted CA cert dir\n", trusted_ca_certs_dir);
1050 trusted_ca_certs_dir, -1);
1051 if ( status != X400_E_NOERROR ) {
1052 fprintf (stderr, "X400msSetStrDefault returned error: %s\n",
1053 X400msError (status));
1054 exit (status);
1055 }
1056
1057 return;
1058}
1059
1060/*
1061 * Obsolete function to use to set up the security environment. This provides a
1062 * directory in which PKCS12 files are checked to find one whose subject DN
1063 * matches that of this client.
1064 *
1065 * Any self signed certificates found in the directory are treated as
1066 * trusted.
1067 */
1068
1069static void setup_default_old_sec_env(
1070 struct X400msSession *sp,
1071 char *id,
1072 char *dn,
1073 char *pw /* passphrase for private key in pkcs12 file */
1074)
1075{
1076 int status;
1077
1078 /* first set a default security identity. This passes in the name of a
1079 * directory, which contains an x509 subdirectory in which all Identities
1080 * are held */
1081 /* X400msSetStrDefault(sp, X400_S_SEC_IDENTITY, "/var/isode/dsa-db/", -1);
1082 * */
1084
1085 /* select by DN which Identity is to be used (if there are several)
1086 * Currently these must be PKCS12 files */
1087 status = X400msSetStrDefault (sp, X400_S_SEC_IDENTITY_DN, dn, -1);
1088 if ( status != X400_E_NOERROR ) {
1089 fprintf (stderr, "X400msSetStrDefault returned error: %s\n",
1090 X400msError (status));
1091 exit (status);
1092 }
1093
1094 /* passphrase used to open the Identity */
1096 if ( status != X400_E_NOERROR ) {
1097 fprintf (stderr, "X400msSetStrDefault returned error: %s\n",
1098 X400msError (status));
1099 exit (status);
1100 }
1101 return;
1102}
1103#endif
1104
1105
1106static int report_moac_info(
1107 struct X400msMessage *mp
1108)
1109{
1110 int status;
1111 int intparam;
1112
1113 /* Check the MOAC */
1114 status = X400msMsgGetIntParam(mp, X400_N_MOAC_STATUS, &intparam);
1115 switch ( status ) {
1116 case X400_E_NO_VALUE:
1117 num_unverified_rcvd++ ;
1118 fprintf (stderr, "No MOAC in message\n");
1119 break;
1120
1121 default:
1122 num_unverified_rcvd++ ;
1123 fprintf (stderr, "Unexpected error getting MOAC status: %s\n",
1124 X400msError (status));
1125 break;
1126
1127 case X400_E_NOERROR:
1128 fprintf (stderr, "Have MOAC in message (%d)\n", intparam);
1129 switch (intparam) {
1130 case X400_E_NOERROR:
1131 fprintf(stderr,
1132 "MsgGet successfully verified signature in message\n");
1133 show_certificate (mp);
1134 fprintf(stderr, "continuing ...\n");
1135 num_verified_rcvd++ ;
1136 break;
1138 fprintf(stderr,
1139 "MOAC validation cannot take place because the security environment is invalid (%d):\n",
1140 intparam);
1141 /* other values will not be available */
1142 break;
1143 case X400_E_X509_INIT:
1144 case X400_E_X509_ENV:
1145 fprintf(stderr,
1146 "MOAC validation cannot take place because the security environment is invalid (%d):\n",
1147 intparam);
1148 /* other values will not be available */
1149 break;
1151 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1152 X400msError(intparam));
1153 show_certificate (mp);
1154 fprintf(stderr, "continuing ...\n");
1155 num_unverified_rcvd++ ;
1156 break;
1158 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1159 X400msError(intparam));
1160 fprintf(stderr, "continuing ...\n");
1161 num_unverified_rcvd++ ;
1162 break;
1164 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1165 X400msError(intparam));
1166 show_certificate (mp);
1167 fprintf(stderr, "continuing ...\n");
1168 num_unverified_rcvd++ ;
1169 break;
1171 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1172 X400msError(intparam));
1173 show_certificate (mp);
1174 fprintf(stderr, "continuing ...\n");
1175 num_unverified_rcvd++ ;
1176 break;
1178 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1179 X400msError(intparam));
1180 show_certificate (mp);
1181 fprintf(stderr, "continuing ...\n");
1182 num_unverified_rcvd++ ;
1183 break;
1185 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1186 X400msError(intparam));
1187 show_certificate (mp);
1188 fprintf(stderr, "continuing ...\n");
1189 num_unverified_rcvd++ ;
1190 break;
1192 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1193 X400msError(intparam));
1194 show_certificate (mp);
1195 fprintf(stderr, "continuing ...\n");
1196 num_unverified_rcvd++ ;
1197 break;
1198 default :
1199 fprintf(stderr, "Unexpected verification error from MsgGet: %s\n",
1200 X400msError(intparam));
1201 show_certificate (mp);
1202 fprintf(stderr, "continuing ...\n");
1203 num_unverified_rcvd++ ;
1204 break;
1205 }
1206 }
1207 return X400_E_NOERROR;
1208}
1209
1210
1211static int report_4406_info(
1212 struct X400msMessage *mp
1213)
1214{
1215 int status;
1216 int intparam;
1217 size_t length;
1218 char buffer[BUFSIZ];
1219
1220 /* Check the 4406 signatures */
1221 status = X400msMsgGetIntParam(mp, X400_N_S4406_STATUS, &intparam);
1222 switch ( status ) {
1223 case X400_E_NO_VALUE:
1224 num_unverified_rcvd++ ;
1225 fprintf (stderr, "No 4406 signature in message\n");
1226 return X400_E_NOERROR;
1227
1228 default:
1229 num_unverified_rcvd++ ;
1230 fprintf (stderr, "Unexpected error getting 4406 signature status: %s\n",
1231 X400msError (status));
1232 break;
1233
1234 case X400_E_NOERROR:
1235 fprintf (stderr, "Have 4406 signature in message (%d)\n", intparam);
1236 switch (intparam) {
1237 case X400_E_NOERROR:
1238 fprintf(stderr,
1239 "MsgGet successfully verified signature in message\n");
1240 show_4406_certificate (mp);
1241 fprintf(stderr, "continuing ...\n");
1242 num_verified_rcvd++ ;
1243 break;
1245 fprintf(stderr,
1246 "4406 signature validation cannot take place because the security environment is invalid (%d):\n",
1247 intparam);
1248 /* other values will not be available */
1249 break;
1250 case X400_E_X509_INIT:
1251 case X400_E_X509_ENV:
1252 fprintf(stderr,
1253 "4406 signature validation cannot take place because the security environment is invalid (%d):\n",
1254 intparam);
1255 /* other values will not be available */
1256 break;
1258 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1259 X400msError(intparam));
1260 show_4406_certificate (mp);
1261 fprintf(stderr, "continuing ...\n");
1262 num_unverified_rcvd++ ;
1263 break;
1265 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1266 X400msError(intparam));
1267 fprintf(stderr, "continuing ...\n");
1268 num_unverified_rcvd++ ;
1269 break;
1271 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1272 X400msError(intparam));
1273 show_4406_certificate (mp);
1274 fprintf(stderr, "continuing ...\n");
1275 num_unverified_rcvd++ ;
1276 break;
1278 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1279 X400msError(intparam));
1280 show_4406_certificate (mp);
1281 fprintf(stderr, "continuing ...\n");
1282 num_unverified_rcvd++ ;
1283 break;
1285 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1286 X400msError(intparam));
1287 show_4406_certificate (mp);
1288 fprintf(stderr, "continuing ...\n");
1289 num_unverified_rcvd++ ;
1290 break;
1292 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1293 X400msError(intparam));
1294 show_4406_certificate (mp);
1295 fprintf(stderr, "continuing ...\n");
1296 num_unverified_rcvd++ ;
1297 break;
1299 fprintf(stderr, "Verification Error from MsgGet: %s\n",
1300 X400msError(intparam));
1301 show_4406_certificate (mp);
1302 fprintf(stderr, "continuing ...\n");
1303 num_unverified_rcvd++ ;
1304 break;
1305 default :
1306 fprintf(stderr, "Unexpected verification error from MsgGet: %s\n",
1307 X400msError(intparam));
1308 show_4406_certificate (mp);
1309 fprintf(stderr, "continuing ...\n");
1310 num_unverified_rcvd++ ;
1311 break;
1312 }
1313 }
1314
1315 /* 4406 security label */
1317 buffer, sizeof buffer, &length);
1318 if (status == X400_E_NO_VALUE) {
1319 printf("No 4406 security label\n");
1320 } else if (status != X400_E_NOERROR) {
1321 fprintf(stderr,"Failed to fetch 4406 security label: %d (%s)",
1322 status, X400msError(status));
1323 return (status);
1324 } else {
1325 fprintf(stderr, "4406 Security Label returned OK (%d chars)\n",
1326 (int)length);
1327 print_sec_label(buffer, length);
1328 }
1329
1330 /* 4406 signing time */
1332 buffer, sizeof buffer, &length);
1333 if (status == X400_E_NOERROR)
1334 printf("4406 signing time returned OK\n%.*s\n", (int)length, buffer);
1335 else
1336 printf("4406 signing time not returned (%d) (%s)\n", status,
1337 X400msError(status));
1338
1339 return X400_E_NOERROR;
1340}
1341
1342static void print_sec_label(
1343 char slab_buffer[],
1344 unsigned int length
1345)
1346{
1347
1348 char xml_buffer[XML_BUFSIZE];
1349 int status;
1350
1351 status = SecLabelInit("Example program");
1352 if (status != SECLABEL_E_NOERROR) {
1353 fprintf(stderr, "SecLabelInit returned error %d\n", status);
1354 return ;
1355 }
1356
1357 status = SecLabelPrint((const unsigned char *) slab_buffer,
1358 length,
1359 xml_buffer,
1360 XML_BUFSIZE);
1361
1362 if (status != SECLABEL_E_NOERROR) {
1363 fprintf(stderr, "SecLabelParse returned error %d\n", status);
1364 return ;
1365 }
1366
1367 /* You could now write out the XML file, or parse it in memory..*/
1368 printf("Got security label:%s\n", xml_buffer);
1369 return;
1370}
1371
1372static void show_certificate (struct X400msMessage *mp)
1373{
1374 int status;
1375 struct X400Certificate *cert;
1376 char buffer[BUFSIZ];
1377 size_t length;
1378 int paramval;
1379
1380 status = X400msMsgGetCert (mp, X400_N_CERT_MOAC, &cert);
1381 if ( status != X400_E_NOERROR ) {
1382 fprintf (stderr, "Error getting MOAC certificate: %s\n",
1383 X400msError (status));
1384 return;
1385 }
1386
1388 buffer, sizeof buffer, &length);
1389 if (status != X400_E_NOERROR) {
1390 fprintf(stderr, "Error from CertGetStrParam: %s\n",
1391 X400msError(status));
1392 return;
1393 }
1394 fprintf(stderr,
1395 "subject DN of originator certificate '%.*s'\n", (int)length, buffer);
1397 buffer, sizeof buffer, &length);
1398 if (status != X400_E_NOERROR) {
1399 fprintf(stderr, "Error from CertGetStrParam: %s\n",
1400 X400msError(status));
1401 return;
1402 }
1403 fprintf(stderr,
1404 "issuer DN of originator certificate '%.*s'\n", (int)length, buffer);
1405
1407 buffer, sizeof buffer, &length);
1408 if (status != X400_E_NOERROR) {
1409 if ( status == X400_E_NO_VALUE ) {
1410 fprintf(stderr, "No ORaddress subject alt. name\n");
1411 } else {
1412 fprintf(stderr, "Error from CertGetStrParam: %s\n",
1413 X400msError(status));
1414 return;
1415 }
1416 } else {
1417 fprintf(stderr, "ORaddress subject alt name: '%.*s'\n", (int)length, buffer);
1418 }
1419
1420 status = X400CertGetIntParam(cert, X400_N_CERT_ORADDRESS_STATUS, &paramval);
1421
1422 if (status != X400_E_NOERROR) {
1423 fprintf(stderr, "Error from CertGetStrParam: %s\n",
1424 X400msError(status));
1425 return;
1426 }
1427
1428 fprintf(stderr, "ORaddress subject alt name status: %s\n",
1429 X400msError (paramval));
1430}
1431
1432
1433static void show_4406_certificate (struct X400msMessage *mp)
1434{
1435 int status;
1436 struct X400Certificate *cert;
1437 char buffer[BUFSIZ];
1438 size_t length;
1439 int paramval;
1440
1441 status = X400msMsgGetCert (mp, X400_N_S4406_CERTIFICATE, &cert);
1442 if ( status != X400_E_NOERROR ) {
1443 fprintf (stderr, "Error getting 4406 certificate: %s\n",
1444 X400msError (status));
1445 return;
1446 }
1447
1449 buffer, sizeof buffer, &length);
1450 if (status != X400_E_NOERROR) {
1451 fprintf(stderr, "Error from CertGetStrParam: %s\n",
1452 X400msError(status));
1453 return;
1454 }
1455 fprintf(stderr, "subject DN of originator certificate '%.*s'\n",
1456 (int)length, buffer);
1458 buffer, sizeof buffer, &length);
1459 if (status != X400_E_NOERROR) {
1460 fprintf(stderr, "Error from CertGetStrParam: %s\n",
1461 X400msError(status));
1462 return;
1463 }
1464 fprintf(stderr, "issuer DN of originator certificate '%.*s'\n",
1465 (int)length, buffer);
1466
1468 buffer, sizeof buffer, &length);
1469 if (status != X400_E_NOERROR) {
1470 if ( status == X400_E_NO_VALUE ) {
1471 fprintf(stderr, "No ORaddress subject alt. name\n");
1472 } else {
1473 fprintf(stderr, "Error from CertGetStrParam: %s\n",
1474 X400msError(status));
1475 return;
1476 }
1477 } else {
1478 fprintf(stderr, "ORaddress subject alt name: '%.*s'\n",
1479 (int)length, buffer);
1480 }
1481
1482 status = X400CertGetIntParam(cert, X400_N_CERT_ORADDRESS_STATUS, &paramval);
1483
1484 if (status != X400_E_NOERROR) {
1485 fprintf(stderr, "Error from CertGetStrParam: %s\n",
1486 X400msError(status));
1487 return;
1488 }
1489
1490 fprintf(stderr, "ORaddress subject alt name status: %s\n",
1491 X400msError (paramval));
1492 return;
1493}
1494
1495static void usage(void) {
1496 printf("usage: %s\n", optstr);
1497 printf("\t where:\n");
1498 printf("\t -u : Don't prompt to override defaults \n");
1499 printf("\t -3 : Use P3 connection \n");
1500 printf("\t -7 : Use P7 connection \n");
1501 printf("\t -m : OR Address in P7 bind arg \n");
1502 printf("\t -d : DN in P7 bind arg \n");
1503 printf("\t -p : Presentation Address of P7 Store \n");
1504 printf("\t -w : P7 password of P7 user \n");
1505 printf("\t -M : OR Address in P3 bind arg \n");
1506 printf("\t -D : DN in P3 bind arg \n");
1507 printf("\t -P : Presentation Address of P3 server\n");
1508 printf("\t -W : P3 password of P3 user \n");
1509 printf("\t -o : Originator \n");
1510 printf("\t -O : Originator Return Address \n");
1511 printf("\t -r : Recipient\n");
1512 printf("\t -l : Logline\n");
1513 printf("\t -y : Priority (0 - normal, 1 - non-urgent, 2 - urgent \n");
1514 printf("\t -C : Content Type (2/22/772/OID) \n");
1515 printf("\t -i : Implicit conversion prohibited = TRUE \n");
1516 printf("\t -a : Alternate Recipient Prohibited = TRUE \n");
1517 printf("\t -q : Content Return Request = TRUE \n");
1518 printf("\t -s : Disclosure of Recipient = FALSE \n");
1519 printf("\t -A : Recipient Reassignment Prohibited = FALSE \n");
1520 printf("\t -v : Conversion with Loss Prohibited = FALSE \n");
1521 printf("\t -e : Security Environment (dir with x509 subdir): obsolete, use -Y <p12file>\n");
1522 printf("\t -x : DN of X.509 Digital Identity\n");
1523 printf("\t -b : Passphrase for private key in PKCS12 file\n");
1524 printf("\t -f : Filename to transfer as binary bp\n");
1525 printf("\t -Y : Filename of PKCS12 file containing Digital Identity\n");
1526 printf("\t -4 : Generate STANAG 4406 PCT Signatures\n");
1527 return;
1528}
1529
1530
#define X400_N_CERT_ORADDRESS_STATUS
Definition x400_att.h:1561
#define X400_S_CERT_ISSUER_DN
Definition x400_att.h:1555
#define X400_S_CERT_SUBJECT_DN
Definition x400_att.h:1552
#define X400_N_CERT_MOAC
Definition x400_att.h:1528
int X400CertGetStrParam(struct X400Certificate *cp, int paramtype, char *buffer, size_t buflen, size_t *paramlenp)
Return a string-valued parameter from the certificate object.
int X400CertGetIntParam(struct X400Certificate *cp, int paramtype, int *valp)
Return a integer-valued parameter from the certificate object.
int X400msMsgAddStrParam(struct X400msMessage *mp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
int X400msMsgGetCert(struct X400msMessage *mp, int certtype, struct X400Certificate **certp)
Get certificate object from message This returns a certificate which was used to sign an object in th...
int X400msRecipGet(struct X400msMessage *mp, int type, int number, struct X400Recipient **rpp)
Get recipient object from message.
int X400msRecipAddIntParam(struct X400Recipient *rp, int paramtype, int value)
Add integer-valued parameter to the message.
int X400msMsgAddIntParam(struct X400msMessage *mp, int paramtype, int value)
Add integer-valued parameter to the message.
int X400msMsgGetStrParam(struct X400msMessage *mp, int paramtype, char *buffer, size_t buflen, size_t *paramlenp)
Return a string-valued parameter from the message object.
int X400msRecipGetStrParam(struct X400Recipient *rp, int paramtype, char *buffer, size_t buflen, size_t *paramlenp)
Return a string-valued parameter from the recipient object.
int X400msRecipNew(struct X400msMessage *mp, int type, struct X400Recipient **rpp)
Add new recipient to a message.
int X400msWait(struct X400msSession *sp, int seconds, int *count)
Wait for messages to be ready to be read.
int X400msMsgGet(struct X400msSession *sp, int number, struct X400msMessage **mpp, int *typep, int *seqp)
Get message object for transfer out from MS or MTA via P3.
const char * X400msError(int error)
Obtain a string describing the meaning of the given error code.
int X400msRecipAddStrParam(struct X400Recipient *rp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
int X400msTestSecurityEnv(struct X400msSession *sp)
Test the default Security Environment.
int X400msSetIntDefault(struct X400msSession *sp, int paramtype, int value)
Set a default integer parameter value in a session.
int X400msMsgSend(struct X400msMessage *mp)
Send message object.
int X400msRecipGetIntParam(struct X400Recipient *rp, int paramtype, int *valp)
Return a integer-valued parameter from the recipient object.
int X400msMsgDelete(struct X400msMessage *mp, int retain)
Delete message object.
int X400msMsgAddAttachment(struct X400msMessage *mp, int type, const char *string, size_t length)
Add attachment to the message.
int X400msMsgNew(struct X400msSession *sp, int type, struct X400msMessage **mpp)
Creates new message.
int X400msClose(struct X400msSession *sp)
Close a X400 Session.
int X400msSetStrDefault(struct X400msSession *sp, int paramtype, const char *value, size_t length)
Set a default string parameter value in a session.
int X400msOpen(int type, const char *oraddr, const char *dirname, const char *credentials, const char *pa, int *messages, struct X400msSession **spp)
Open a session to a Message Store (P7) or MTA (P3) in synchronous mode.
int X400msMsgGetIntParam(struct X400msMessage *mp, int paramtype, int *valp)
Return a integer-valued parameter from the message object.
#define X400_S_DIRECTORY_NAME
Definition x400_att.h:397
#define X400_S_OR_ADDRESS
Definition x400_att.h:349
#define X400_S_SUBJECT
Definition x400_att.h:749
#define X400_T_BINARY
Definition x400_att.h:851
#define X400_T_IA5TEXT
Definition x400_att.h:825
#define X400_T_ISO8859_1
Definition x400_att.h:835
#define X400_B_RETURN_VERIFICATION_ERRORS
Definition x400_att.h:1123
#define X400_S_LOG_CONFIGURATION_FILE
Definition x400_att.h:1116
#define X400_S_MESSAGE_DELIVERY_TIME
Definition x400_att.h:451
#define X400_S_CONTENT_IDENTIFIER
Definition x400_att.h:425
#define X400_S_MESSAGE_IDENTIFIER
Definition x400_att.h:416
#define X400_S_SECURITY_LABEL
Definition x400_att.h:1370
#define X400_E_X509_CERT_INVALID
Definition x400_att.h:199
#define X400_E_X509_VERIFY_FAIL
Definition x400_att.h:196
#define X400_E_SIGN_NO_IDENTITY
Definition x400_att.h:205
#define X400_E_X509_ITEM_INVALID
Definition x400_att.h:202
#define X400_E_SYSERROR
Definition x400_att.h:49
#define X400_E_NOMEMORY
Definition x400_att.h:52
#define X400_E_X509_ENV
Definition x400_att.h:175
#define X400_E_NOERROR
Definition x400_att.h:46
#define X400_E_NO_VALUE
Definition x400_att.h:100
#define X400_E_INVALID_ATTR
Definition x400_att.h:94
#define X400_E_X509_VERIFY_FAIL_NO_CERT
Definition x400_att.h:184
#define X400_E_X509_VERIFY_FAIL_UNSUPPORTED_ALG
Definition x400_att.h:193
#define X400_E_X509_VERIFY_FAIL_NO_PUBKEY
Definition x400_att.h:187
#define X400_E_X509_VERIFY_FAIL_INCOMPAT_ALG
Definition x400_att.h:190
#define X400_E_X509_INIT
Definition x400_att.h:181
#define X400_E_NO_RECIP
Definition x400_att.h:109
#define X400_MSG_MESSAGE
Definition x400_att.h:29
#define X400_N_REPORT_REQUEST
Definition x400_att.h:680
#define X400_N_NOTIFICATION_REQUEST
Definition x400_att.h:702
#define X400_RECIP_PRIMARY
Definition x400_att.h:296
#define X400_RECIP_STANDARD
Definition x400_att.h:341
#define X400_RECIP_REPORT
Definition x400_att.h:314
#define X400_S_SUPPLEMENTARY_INFO
Definition x400_att.h:1067
#define X400_S_SUBJECT_IDENTIFIER
Definition x400_att.h:1064
#define X400_N_NON_DELIVERY_REASON
Definition x400_att.h:1076
#define X400_N_NON_DELIVERY_DIAGNOSTIC
Definition x400_att.h:1079
#define X400_N_S4406_STATUS
Definition x400_att.h:635
#define X400_N_S4406_CERTIFICATE
Definition x400_att.h:651
#define X400_N_MOAC_STATUS
Definition x400_att.h:594
#define X400_S_SEC_IDENTITY_DN
Definition x400_att.h:572
#define X400_B_SEC_GEN_MOAC
Definition x400_att.h:566
#define X400_N_S4406
Definition x400_att.h:626
#define X400_S_SEC_IDENTITY_FILE
Definition x400_att.h:600
#define X400_S_SEC_TRUSTED_CERTS_DIR
Definition x400_att.h:603
#define X400_S_S4406_SIGNING_TIME
Definition x400_att.h:656
#define X400_S_SEC_IDENTITY
Definition x400_att.h:563
#define X400_S_S4406_SECURITY_LABEL
Definition x400_att.h:646
#define X400_S_SEC_IDENTITY_PASSPHRASE
Definition x400_att.h:569
X400 MA/MS (P3/P7) Interface.

All rights reserved © 2002 - 2024 Isode Ltd.