]> git.saurik.com Git - apple/security.git/blame - SecuritySNACCRuntime/c++-examples/simple/README
Security-54.1.3.tar.gz
[apple/security.git] / SecuritySNACCRuntime / c++-examples / simple / README
CommitLineData
bac41a7b
A
1(RCS control information is at the end of this file.)
2
3
4C++ Simple Example README
5-------------------------
6
7This directory should have 6 files in it:
8
9 README - this file
10
11 genber.C - C++ source code for a program that creates and encodes
12 a PersonnelRecord value to a file.
13
14 example.C - C++ source code for a program that decodes a given
15 PersonnelRecord value and re-encodes it to stdout.
16
17 makefile - compiles the example programs
18
19 good_pr.ber - BER encoding of a Personnel Record (all definite lengths)
20
21
22
23Type "make" to generate the 3 example programs:
24 genber
25 def
26 indef
27
28
29
30snacc is called from the makefile on .../asn1specs/p_rec.asn1 to
31generate the following files:
32
33p_rec.h - C++ classes for PersonnelRecord types.
34
35p_rec.C - C++ source code for the PersonnelRecord encode, decode,
36 print, and free methods.
37
38These source files are then compiled with example.C to make the
39programs def and indef. Each program takes 1 argument, the name of a
40file containing an BER encoded PersonnelRecord value.
41
42
43Try the following:
44
45%1 genber # create a file called pr.ber
46%2 indef good_pr.ber > indef_pr.ber
47%3 def indef_pr.ber > def_pr.ber
48%4 diff good_pr.ber def_pr.ber # should be no differences
49
50(commands 2-4 can be made via the `check' phony target.)
51
52The above commands decode the BER value in "good_pr.ber" and
53indef_pr.ber respectively and then re-encode them to stdout.
54Both programs will decode any valid BER representation of a
55PersonnelRecord value but, the def program will re-encode the
56given data using only the definite length BER format and the
57indef program will re-encode the given data using only the
58indefinite length BER format.
59
60Compare the lengths of the def_pr.ber and indef_pr.ber files,
61indefinite length encodings are usually larger.
62
63
64
65Things to Note
66--------------
67
68Look at genber.C to see how to build a C++ value and then encode it.
69look at the example.C file to see buffer usage. Look at
70.../c++_lib/inc/asn_config.h and .../c++_lib/inc/asn_buf.h if you
71want to change the buffer managment.
72
73
74Snacc ASN.1 comment commands
75
76Notice the special "--snacc" ASN.1 comment in .../asn1specs/p_rec.asn1.
77
78PersonnelRecord ::= --snacc isPdu:"TRUE" -- [APPLICATION 0] IMPLICIT SET
79 { ... etc. ... }
80
81The "isPdu" flag tells snacc that the PersonnelRecord is a PDU type.
82This flag has no effect on the generated C++ code, since each type gets
83PDU members automatically for C++.
84
85
86
87Length formats
88
89Both the def and indef programs were generated from the same source
90file, example.c. Indefinite length encoders can be created by giving
91the -DUSE_INDEF_LEN flag to the C++ compiler when compiling. Currently
92the indefinite/definite length encoder choice is made a compile time.
93To change this to a run-time decision, a simple solution would be to
94modify BerEncodeConsLen and BerEncodeEocIfNec macros in
95.../c++_lib/inc/asn_len.h to check a global flag.
96
97#-------------------------------------------------------------------------------
5a719ac8 98# $Header: /cvs/Darwin/src/live/Security/SecuritySNACCRuntime/c++-examples/simple/README,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $
bac41a7b
A
99# $Log: README,v $
100# Revision 1.1.1.1 2001/05/18 23:14:05 mb
101# Move from private repository to open source repository
102#
103# Revision 1.1.1.1 1999/03/16 18:05:57 aram
104# Originals from SMIME Free Library.
105#
106# Revision 1.2 1994/10/08 04:43:46 rj
107# the test csh skript has been integrated into the makefile
108#
109# Revision 1.1 1994/08/31 08:48:05 rj
110# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
111#