x400_mssend_sign.c
1/* Copyright (c) 2003-2014, 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 * @VERSION@
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#include <errno.h>
22
23#include <x400_msapi.h>
24#include <seclabel_api.h> /* For security labels */
25
26#include "example.h"
27#include "ms_example.h"
28#include "time.h"
29
30#define PCT_OID "1.2.840.113549.1.9.16.1.6"
31
32static 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:Z4B:F:N:";
33
34/* These are the data items used to construct the message for submission */
35static char *default_recip = "/CN=lppt1/OU=lppt/O=attlee/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
36char *recip;
37static char *content_id = "030924.140212";
38
39static const char text[] = "First line\r\nSecond line\r\n";
40
41static char *binary_data;
42
43static int setup_msg_sec_env = 0;
44
45/* set this to non zero to cause the IA5 body part to be an attachment */
46int send_ia5_as_att = 0;
47
48/* local functions */
49
50static void usage(void) ;
51static int send_msg(
52 int contype,
53 char *orn,
54 char *def_dn,
55 char *pa,
56 char *password);
57
58static int submit_msg(
59 char *orn,
60 struct X400msSession *sp /* session object */
61);
62
63static int setup_default_new_sec_env(
64 struct X400msSession *sp,
65 char *identity_filename,
66 char *pw
67);
68
69static int setup_default_old_sec_env(
70 struct X400msSession *sp,
71 char *id,
72 char *dn,
73 char *pw
74);
75
76static int setup_msg_new_sec_env(
77 struct X400msMessage *mp, /* message object */
78 char *identity_filename,
79 char *pw
80);
81
82static int setup_msg_old_sec_env(
83 struct X400msMessage *mp, /* message object */
84 char *id,
85 char *dn,
86 char *pw
87);
88
89
90static int add_content(
91 struct X400msMessage *mp /* message object */
92);
93
94/* start here */
95int main (
96 int argc,
97 char **argv
98)
99{
100 char pa[BUFSIZ];
101 char orn[BUFSIZ];
102 char *def_oraddr;
103 char *def_dn;
104 char *def_pa;
105 int contype;
106 int status;
107 char password[BUFSIZ];
108
109 if (get_args(argc, argv, optstr)) {
110 usage();
111 exit(-1);
112 }
113
114 printf("Connection type (0 = P7, 1 = P3 submit only, 2 = P3 both directions) [%d]: ", x400_contype);
115 contype = ic_fgetc(x400_contype, stdin);
116 if (contype != 10)
117 ic_fgetc(x400_contype, stdin);
118
119 if ( contype < '0' || '2' < contype )
120 contype = x400_contype;
121 else
122 contype -= '0';
123
124 if (contype == 0) {
125 def_oraddr = x400_ms_user_addr;
126 def_dn = x400_ms_user_dn;
127 def_pa = x400_ms_presentation_address;
128 } else {
129 def_oraddr = x400_mta_user_addr;
130 def_dn = x400_mta_user_dn;
131 def_pa = x400_mta_presentation_address;
132 }
133
134 printf("Your ORAddress [%s] > ", def_oraddr);
135 ic_fgets (orn, sizeof orn, stdin);
136
137 if ( orn[strlen(orn)-1] == '\n' )
138 orn[strlen(orn)-1] = '\0';
139
140 if (orn[0] == '\0')
141 strcpy(orn, def_oraddr);
142
143 /* Prompt for password; note: reflected. */
144 printf ("Password [%s]: ",
145 contype == 0 ? x400_p7_password : x400_p3_password);
146 if ( ic_fgets (password, sizeof password, stdin) == NULL )
147 exit (1);
148
149 if (password[strlen(password)-1] == '\n' )
150 password[strlen(password)-1] = '\0';
151 if (password[0] == '\0')
152 strcpy(password, contype == 0 ? x400_p7_password : x400_p3_password);
153
154 /* Presentation Address */
155 printf("Presentation Address [%s] > ", def_pa);
156 ic_fgets (pa, sizeof pa, stdin);
157
158 if ( pa[strlen(pa)-1] == '\n' )
159 pa[strlen(pa)-1] = '\0';
160
161 if (pa[0] == '\0')
162 strcpy(pa, def_pa);
163
164 printf("sending message using session 1\n");
165 if ((status = send_msg(contype, orn, def_dn, pa, password))
166 != X400_E_NOERROR ) {
167 fprintf (stderr, "Error in sending message\n");
168 exit (status);
169 }
170 /*
171 printf("sending message using session 2\n");
172 if ((status = send_msg(contype, orn, def_dn, pa, password))
173 != X400_E_NOERROR ) {
174 fprintf (stderr, "Error sending message\n");
175 exit (status);
176 }
177 */
178 return (status);
179}
180
181static int send_msg(
182 int contype,
183 char *orn,
184 char *def_dn,
185 char *pa,
186 char *password
187)
188{
189 struct X400msSession *sp; /* session object */
190
191 int status;
192
193
194 /* we've got what we need - now open an API session */
195 status = X400msOpen (contype, orn, def_dn, password, pa, NULL, &sp);
196 if ( status != X400_E_NOERROR ) {
197 fprintf (stderr, "Error in Open: %s\n", X400msError (status));
198 fprintf (stderr, "%s %s %s\n", orn, def_dn, pa);
199 return (status);
200 }
201
202 /* setup logging */
204
205 /* Set up the security environment.
206 *
207 * The security env can be specified the new way (recommended) using
208 * a PKCS12 filename and passphrase, or as a directory (deprecated and
209 * obsolete).
210 *
211 * If the ID is specified as a directory, in which the subdirectory
212 * "x509" is expected to contain one or more PKCS12 files.
213 * The appropriate Digital Identity is determined from the
214 * DN of the subject, and the passphrase is used to decrypt
215 * the private key.
216 */
217 if (use_new_sec_env) {
218 status = setup_default_new_sec_env(sp, identity_filename, passphrase);
219 } else {
220 status = setup_default_old_sec_env(sp, security_id, identity_dn,
221 passphrase);
222 }
223
224 if ( status != X400_E_NOERROR ) {
225 fprintf (stderr, "Can't setup security environment\n");
226 return (status);
227 }
228
229 printf("sending message 1\n");
230 status = submit_msg(orn, sp);
231 if ( status != X400_E_NOERROR ) {
232 fprintf (stderr, "Can't submit\n");
233 return (status);
234 }
235
236 status = X400msClose (sp);
237 if ( status != X400_E_NOERROR ) {
238 fprintf (stderr, "X400msClose returned error: %s\n", X400msError (status));
239 return (status);
240 }
241 return status;
242}
243
244static int submit_msg(
245 char *orn,
246 struct X400msSession *sp /* session object */
247)
248{
249 struct X400msMessage *mp; /* message object */
250 struct X400Recipient *rp; /* recipient object */
251 char tmp[BUFSIZ];
252 FILE *fp = NULL;
253 int fs=0;
254 int status;
255
256 if (x400_default_recipient != NULL)
257 recip = x400_default_recipient;
258 else
259 recip = default_recip;
260
261 printf("Message recipient [%s]: ", recip);
262 ic_fgets (tmp, sizeof tmp, stdin);
263
264 if ( tmp[strlen(tmp)-1] == '\n' )
265 tmp[strlen(tmp)-1] = '\0';
266 if (strlen(tmp) != 0)
267 recip = strdup(tmp);
268
269 printf("Subject [%s]: ", subject);
270 ic_fgets (tmp, sizeof tmp, stdin);
271
272 if ( tmp[strlen(tmp)-1] == '\n' )
273 tmp[strlen(tmp)-1] = '\0';
274 if (strlen(tmp) != 0)
275 subject = strdup(tmp);
276
277 status = X400msMsgNew (sp, X400_MSG_MESSAGE, &mp);
278 if ( status != X400_E_NOERROR ) {
279 fprintf (stderr, "x400msMsgNew returned error: %s\n", X400msError (status));
280 return (status);
281 }
282
283 printf("\n\nPreparing Message\n");
284
285 /* set content type */
286 if (x400_default_external_content_type != NULL) {
287 printf("Sending external content type %s\n",
288 x400_default_external_content_type);
290 x400_default_external_content_type, -1);
291 } else {
292 printf("Sending content type %d\n", x400_default_content_type);
294 x400_default_content_type);
295 }
296 if ( status != X400_E_NOERROR ) {
297 fprintf (stderr, "X400msMsgAddIntParam returned error: %s\n",
298 X400msError (status));
299 return (status);
300 }
301
302 /* Set up the security environment for this message overriding the
303 * default security env.
304 *
305 * The security env can be specified the new way (recommended) using
306 * a PKCS12 filename and passphrase, or as a directory (deprecated and
307 * obsolete).
308 *
309 * If the ID is specified as a pathname, in which the subdirectory
310 * "x509" is expected to contain one or more PKCS12 files.
311 * The appropriate Digital Identity is determined from the
312 * DN of the subject, and the passphrase is used to decrypt
313 * the private key.
314 */
315 if (setup_msg_sec_env) {
316 if (use_new_sec_env) {
317 status = setup_msg_new_sec_env(mp, identity_filename, passphrase);
318 if ( status != X400_E_NOERROR ) {
319 fprintf (stderr, "Can't setup new security environment\n");
320 return (status);
321 }
322 } else {
323 status = setup_msg_old_sec_env(mp, security_id, identity_dn2,
324 passphrase);
325 if ( status != X400_E_NOERROR ) {
326 fprintf (stderr, "Can't setup old security environment\n");
327 return (status);
328 }
329 }
330 }
331
332 /* Instruct the X400msMsgSend() function to generate a MOAC (signature) for
333 * the message.
334 *
335 * The default attributes will be used unless the attributes are
336 * also included in the message eg by calling setup_msg_sec_env() above
337 */
338 if (gen_moac) {
340 if ( status != X400_E_NOERROR ) {
341 fprintf (stderr, "x400msMsgAddIntParam returned error: %s\n",
342 X400msError (status));
343 return (status);
344 }
345 }
346
347 if (gen_4406_sig) {
348 /* Instruct the X400msMsgSend() function to generate a STANAG 4406
349 * signature for the message
350 *
351 * The default attributes will be used unless the attributes are
352 * also included in the message
353 * e.g. by calling setup_msg_sec_env() above
354 */
355 printf("\nRequesting 4406 signature\n");
356 status = X400msMsgAddIntParam (mp, X400_N_S4406, 1);
357 if ( status != X400_E_NOERROR ) {
358 fprintf (stderr, "x400msMsgAddIntParam returned error: %s\n",
359 X400msError (status));
360 return (status);
361 }
362 /* set the external content type correctly to PCT */
364 PCT_OID, -1);
365 printf("Sending external content type %s\n", PCT_OID);
366 } else {
367 printf("\nNot requesting 4406 signature\n");
368 }
369
370 status = add_sec_label (mp);
371 if ( status != X400_E_NOERROR ) {
372 fprintf (stderr, "Failed to add 4406 Security Label: %s\n",
373 X400msError (status));
374 return (status);
375 }
376
377 status = X400msRecipNew (mp, X400_RECIP_STANDARD, &rp);
378 if ( status != X400_E_NOERROR ) {
379 fprintf (stderr, "x400msRecipNew returned error: %s\n", X400msError (status));
380 return (status);
381 }
382
383 /* put precedence extension into primary recipient */
385 if ( status != X400_E_NOERROR ) {
386 fprintf (stderr, "x400msRecipAddIntParam returned error: %s\n",
387 X400msError (status));
388 return (status);
389 }
390
391 status = X400msRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip, -1);
392 if ( status != X400_E_NOERROR ) {
393 fprintf (stderr, "x400msRecipAddStrParam returned error: %s\n", X400msError (status));
394 return (status);
395 }
396
397 status = X400msRecipAddStrParam (rp, X400_S_DIRECTORY_NAME, "CN=recipient;c=gb", -1);
398 if ( status != X400_E_NOERROR ) {
399 fprintf (stderr, "x400msRecipAddStrParam returned error: %s\n", X400msError (status));
400 return (status);
401 }
402
403 status = X400msMsgAddStrParam (mp, X400_S_OR_ADDRESS, orn, -1);
404 if ( status != X400_E_NOERROR ) {
405 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n", X400msError (status));
406 return (status);
407 }
408
409 status = X400msMsgAddStrParam (mp, X400_S_DIRECTORY_NAME, "CN=originator;c=gb", -1);
410 if ( status != X400_E_NOERROR ) {
411 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n", X400msError (status));
412 return (status);
413 }
414
415 /* Ask for +ve and -ve delivery reports */
417 if ( status != X400_E_NOERROR ) {
418 fprintf (stderr, "x400msRecipAddStrParam returned error: %s\n", X400msError (status));
419 return (status);
420 }
421
422 /* Ask for +ve and -ve read receipts */
424 if ( status != X400_E_NOERROR ) {
425 fprintf (stderr, "x400msRecipAddStrParam returned error: %s\n", X400msError (status));
426 return (status);
427 }
428
430 content_id, -1);
431 if ( status != X400_E_NOERROR ) {
432 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n", X400msError (status));
433 return (status);
434 }
435
436 /* subject */
437 {
438 time_t t;
439 time(&t);
440 char tmp_buffer[255];
441 // NB strip newline from ctime result
442 snprintf(tmp_buffer, 244, "%s '%s' '%.19s'",
443 subject, get_x400_pty_str_from_4406(x400_default_priority), ctime(&t));
444 printf("Subject is '%s'\n", tmp_buffer);
445 status = X400msMsgAddStrParam (mp, X400_S_SUBJECT, tmp_buffer, -1);
446 if ( status != X400_E_NOERROR ) {
447 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n",
448 X400msError (status));
449 exit (status);
450 }
451 }
452
453 /* put FLOT into IA5 BP */
454 if (flot_string != NULL) {
455 status = X400msMsgAddStrParam (mp, X400_T_IA5TEXT, flot_string, -1);
456 if ( status != X400_E_NOERROR ) {
457 fprintf (stderr, "x400ms returned error: %s\n",
458 X400msError (status));
459 return (status);
460 }
461 printf("Sent IA5 FLOT:\n%s\n", flot_string);
462 }
463
464 if (add_content(mp) != X400_E_NOERROR) {
465 fprintf (stderr, "add_content() returned error: %s\n",
466 X400msError (status));
467 return (status);
468 }
469
470 status = X400msMsgAddStrParam (mp, X400_T_ISO8859_1, text, -1);
471 if ( status != X400_E_NOERROR ) {
472 fprintf (stderr, "x400ms returned error: %s\n", X400msError (status));
473 return (status);
474 }
475 printf("Sent 8859 content:\n%s\n", text);
476
477 /* now an IA5 body part using the bodypart func */
478 status = X400msMsgAddAttachment (mp, X400_T_IA5TEXT, text, strlen(text));
479 if ( status != X400_E_NOERROR ) {
480 printf("failed to add X400_T_IA5TEXT BP\n");
481 return (status);
482 }
483 printf("Sent IA5 content:\n%s\n", text);
484
485 /* or a Binary body part using the bodypart func */
486 if (filename_to_send != NULL) {
487 binary_data = (char *) malloc(100000);
488 if ( binary_data == NULL )
489 return X400_E_NOMEMORY;
490 fp = fopen(filename_to_send, "r");
491 if (fp == (FILE *)NULL) {
492 printf("Cannot open binary file\n");
493 return (X400_E_SYSERROR);
494 }
495 if ((fs = fread (binary_data, sizeof(char), 100000/sizeof(char), fp) ) == -1) {
496 printf("Cannot read from binary file\n");
497 return (X400_E_SYSERROR);
498 }
499 fclose(fp);
500
501 status = X400msMsgAddAttachment (mp, X400_T_BINARY, binary_data, fs);
502 if ( status != X400_E_NOERROR ) {
503 printf("failed to add X400_T_BINARY BP\n");
504 return (status);
505 }
506 } else {
507 printf("no binary file set - not sending X400_T_BINARY\n");
508 }
509
510 status = X400msMsgSend (mp);
511 if ( status != X400_E_NOERROR ) {
512 fprintf (stderr, "x400msMsgSend returned error: %s\n", X400msError (status));
513 return (status);
514 } else {
515 printf("Message submitted successfully\n");
516 }
517
518 status = X400msMsgDelete (mp, 0);
519 if ( status != X400_E_NOERROR ) {
520 fprintf (stderr, "x400msMsgDelete returned error: %s\n", X400msError (status));
521 return (status);
522 }
523
524 mp = NULL;
525 rp = NULL;
526
527 return (status);
528}
529
530
531static int setup_default_new_sec_env(
532 struct X400msSession *sp,
533 char *identity,
534 char *pw
535)
536{
537 int status;
538
539 /* Filename of the Digital Identity (PKCS12 file) */
541 identity, -1);
542 if ( status != X400_E_NOERROR ) {
543 fprintf (stderr, "X400msSetStrDefault returned error: %s\n",
544 X400msError (status));
545 return (status);
546 }
547
548 /* Passphrase of the private key in the above Digital Identity */
550 if ( status != X400_E_NOERROR ) {
551 fprintf (stderr, "X400msSetStrDefault returned error: %s\n",
552 X400msError (status));
553 return (status);
554 }
555
556 /* test the sec env */
557 status = X400msTestSecurityEnv (sp);
558 if ( status != X400_E_NOERROR ) {
559 fprintf (stderr, "X400msTestSecurityEnv returned error: %s\n",
560 X400msError (status));
561 return (status);
562 }
563
564 printf ("X400msTestSecurityEnv returned success\n");
565
566 return status;
567}
568
569static int setup_default_old_sec_env(
570 struct X400msSession *sp,
571 char *id,
572 char *dn,
573 char *pw
574)
575{
576 int status;
577
578 /* first set a default security identity. This passes in the name of a
579 * directory, which contains an x509 subdirectory in which all Identities
580 * are held */
582
583 /* select by DN which Identity is to be used (if there are several)
584 * Currently these must be PKCS12 files */
585 status = X400msSetStrDefault (sp, X400_S_SEC_IDENTITY_DN, dn, -1);
586 if ( status != X400_E_NOERROR ) {
587 fprintf (stderr, "X400msSetStrDefault returned error: %s\n",
588 X400msError (status));
589 return (status);
590 }
591
592 /* Passphrase of the private key in the above Digital Identity */
594 if ( status != X400_E_NOERROR ) {
595 fprintf (stderr, "X400msSetStrDefault returned error: %s\n",
596 X400msError (status));
597 return (status);
598 }
599
600 return status;
601}
602
603static int setup_msg_new_sec_env(
604 struct X400msMessage *mp, /* message object */
605 char *identity,
606 char *pw
607)
608{
609 int status;
610
611 /* Filename of the Digital Identity (PKCS12 file) */
613 identity, -1);
614 if ( status != X400_E_NOERROR ) {
615 fprintf (stderr, "X400msMsgAddStrParam returned error: %s\n",
616 X400msError (status));
617 return (status);
618 }
619
620 /* Passphrase of the private key in the above Digital Identity */
622 if ( status != X400_E_NOERROR ) {
623 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n",
624 X400msError (status));
625 return (status);
626 }
627 return (status);
628}
629
630static int setup_msg_old_sec_env(
631 struct X400msMessage *mp, /* message object */
632 char *id,
633 char *dn,
634 char *pw
635)
636{
637 int status;
638
639 /* overide the default security environment by specifying a new set of
640 * attibutes, and put them into the message */
641 /* security additions */
642 status = X400msMsgAddStrParam (mp, X400_S_SEC_IDENTITY, id, -1);
643 /* status = X400msMsgAddStrParam (mp, X400_S_SEC_IDENTITY, "/var/isode/dsa-db", -1); */
644 if ( status != X400_E_NOERROR ) {
645 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n",
646 X400msError (status));
647 return (status);
648 }
649
650 /* security additions */
651 status = X400msMsgAddStrParam (mp, X400_S_SEC_IDENTITY_DN, dn, -1);
652 if ( status != X400_E_NOERROR ) {
653 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n",
654 X400msError (status));
655 return (status);
656 }
657
658 /* security additions */
660 if ( status != X400_E_NOERROR ) {
661 fprintf (stderr, "x400msMsgAddStrParam returned error: %s\n",
662 X400msError (status));
663 return (status);
664 }
665 return (status);
666}
667
668
669static int add_content(
670 struct X400msMessage *mp /* message object */
671)
672{
673 FILE *fp = NULL;
674 int fs = 0;
675 int status;
676
677 /* add some attachments/body parts
678 * Strictly a message simply has a sequence of body parts.
679 * However in human terms, it can be useful to treat the Body Parts
680 * as
681 * - text, i.e. an IA5 or general text attachment
682 * - followed by 0 or more attachments (e.g. documents, images etc)
683 *
684 * The API allows for either style.
685 *
686 * Use the AddStrParam() function to add a text attachment
687 * Use the X400msMsgAddAttachment() function to add a Body Part
688 * Use the X400msMsgAddMessageBodyWType() function to add structured
689 * Body Part (e.g. message, FTBP)
690 */
691
692 status = X400msMsgAddStrParam (mp, X400_T_ISO8859_1, text, -1);
693 if ( status != X400_E_NOERROR ) {
694 fprintf (stderr, "x400ms returned error: %s\n", X400msError (status));
695 return (status);
696 }
697 printf("Sent 8859 attachment as string:\n%s\n", text);
698
699 if (send_ia5_as_att) {
700 /* now an IA5 body attachment using the attachment func */
702 text, strlen(text));
703 if ( status != X400_E_NOERROR ) {
704 printf("failed to add X400_T_IA5TEXT attachment\n");
705 return (status);
706 }
707 printf("Sent IA5 as first attachment:\n%s\n", text);
708 } else {
709 /* now an IA5 attachment using the str func */
710 status = X400msMsgAddStrParam (mp, X400_T_IA5TEXT, text, -1);
711 if ( status != X400_E_NOERROR ) {
712 printf("failed to add X400_T_IA5TEXT BP\n");
713 return (status);
714 }
715 printf("Sent IA5 as string in message \n%s\n", text);
716 }
717
718 /* now an 8859-1 body attachment using the attachment func */
719 status = X400msMsgAddAttachment (mp, X400_T_ISO8859_1, text, strlen(text));
720 if ( status != X400_E_NOERROR ) {
721 printf("failed to add X400_T_ISO8859_1, attachment\n");
722 return (status);
723 }
724 printf("Sent 8859-1 as attachment:\n%s\n", text);
725
726 /* or a Binary body part using the bodypart func */
727 if (filename_to_send != NULL) {
728 binary_data = (char *) malloc(100000);
729 if ( binary_data == NULL )
730 return X400_E_NOMEMORY;
731 fp = fopen(filename_to_send, "r");
732 if (fp == (FILE *)NULL) {
733 printf("Cannot open binary file\n");
734 return (X400_E_SYSERROR);
735 }
736 if ((fs = fread (binary_data, sizeof(char), 100000/sizeof(char), fp))
737 == -1) {
738 printf("Cannot read from binary file\n");
739 return (X400_E_SYSERROR);
740 }
741 fclose(fp);
742
743 status = X400msMsgAddAttachment (mp, X400_T_BINARY, binary_data, fs);
744 if ( status != X400_E_NOERROR ) {
745 printf("failed to add X400_T_BINARY BP\n");
746 return (status);
747 }
748
749 free (binary_data);
750
751 } else {
752 printf("no binary file set - not sending X400_T_BINARY\n");
753 }
754 return status;
755}
756
757static void usage(void) {
758 printf("usage: %s\n", optstr);
759 printf("\t where:\n");
760 printf("\t -u : Don't prompt to override defaults \n");
761 printf("\t -3 : Use P3 connection \n");
762 printf("\t -7 : Use P7 connection \n");
763 printf("\t -m : OR Address in P7 bind arg \n");
764 printf("\t -d : DN in P7 bind arg \n");
765 printf("\t -p : Presentation Address of P7 Store \n");
766 printf("\t -w : P7 password of P7 user \n");
767 printf("\t -M : OR Address in P3 bind arg \n");
768 printf("\t -D : DN in P3 bind arg \n");
769 printf("\t -P : Presentation Address of P3 server\n");
770 printf("\t -W : P3 password of P3 user \n");
771 printf("\t -o : Originator \n");
772 printf("\t -O : Originator Return Address \n");
773 printf("\t -r : Recipient\n");
774 printf("\t -l : Logline\n");
775 printf("\t -y : Military Priority \n");
776 printf("\t\t 0 - deferred, 1 - routine, 2 - priority \n");
777 printf("\t\t 3 - immediate, 4 - flash, 5 - override \n");
778 printf("\t -C : Content Type (2/22/772/OID) \n");
779 printf("\t -i : Implicit conversion prohibited = TRUE \n");
780 printf("\t -a : Alternate Recipient Prohibited = TRUE \n");
781 printf("\t -q : Content Return Request = TRUE \n");
782 printf("\t -s : Disclosure of Recipient = FALSE \n");
783 printf("\t -A : Recipient Reassignment Prohibited = FALSE \n");
784 printf("\t -v : Conversion with Loss Prohibited = FALSE \n");
785 printf("\t -e : Security Environment (dir with x509 subdir): obsolete, use -Y <p12file>\n");
786 printf("\t -x : DN of X.509 Digital Identity\n");
787 printf("\t -b : Passphrase for private key in PKCS12 file\n");
788 printf("\t -f : Filename to transfer as binary bp\n");
789 printf("\t -Y : Filename of PKCS12 file containing Digital Identity\n");
790 printf("\t -Z : Generate MOAC Signature\n");
791 printf("\t -4 : Generate STANAG 4406 PCT Signatures\n");
792 printf("\t -B : Subject of message\n");
793 printf("\t -F : String to insert in first line of text (e.g. as FLOT)\n");
794 printf("\t -N : Insert Security Label in (e)nvelope or (4)406 signature\n");
795 return;
796}
797
798
int X400msMsgAddStrParam(struct X400msMessage *mp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the 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 X400msRecipNew(struct X400msMessage *mp, int type, struct X400Recipient **rpp)
Add new recipient to a message.
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 X400msMsgSend(struct X400msMessage *mp)
Send message 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.
#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_S_LOG_CONFIGURATION_FILE
Definition x400_att.h:1116
#define X400_S_CONTENT_IDENTIFIER
Definition x400_att.h:425
#define X400_N_CONTENT_TYPE
Definition x400_att.h:419
#define X400_S_EXTERNAL_CONTENT_TYPE
Definition x400_att.h:456
#define X400_E_SYSERROR
Definition x400_att.h:49
#define X400_E_NOMEMORY
Definition x400_att.h:52
#define X400_E_NOERROR
Definition x400_att.h:46
#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_N_PRECEDENCE
Definition x400_att.h:712
#define X400_RECIP_STANDARD
Definition x400_att.h:341
#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_IDENTITY
Definition x400_att.h:563
#define X400_S_SEC_IDENTITY_PASSPHRASE
Definition x400_att.h:569
X400 MA/MS (P3/P7) Interface.

All rights reserved © 2002 - 2024 Isode Ltd.