RSA Security 5.2.2 Projection Television User Manual


 
System Considerations In Crypto-C
124 RSA BSAFE Crypto-C Developers Guide
more individuals. For example, users may need to transmit a public key, elliptic curve
parameters, or an algorithm name. Not everyone uses Crypto-C, and how
information is processed in Crypto-C may be different from another companys
package. There needs to be a standard for describing certain information. BER/DER is
such a standard.
Open Systems Interconnection (OSI, described in ANSIs X.200) is an internationally
standardized architecture that governs the interconnection of computers from the
physical layer up to the user-application layer. OSIs method of specifying abstract
objects is called ASN.1 (Abstract Syntax Notation One, defined in X.680), and one set
of rules for representing such objects as strings of ones and zeros is called BER (Basic
Encoding Rules, defined in X.680). There is generally more than one way to BER-
encode a given value, so another set of rules, called the Distinguished Encoding Rules
(DER), which is a subset of BER, gives a unique encoding to each ASN.1 value. The
PKCS document includes A Laymans Guide to a Subset of ASN.1, BER and DER,
which is more accessible than the actual standard.
If your application must transfer information to another computer or software
package, you may need to convert the data into BER-encoded format before you send
it. Crypto-C offers a way to get information into DER format, using
B_GetAlgorithmInfo or B_GetKeyInfo with the BER version of the AI or KI used to set
the algorithm or key object.
The following example corresponds to the file
berder.c.
In the Introductory Example on page 9, we set the algorithm object to
AI_RC4. The
Reference Manual Chapter 2 entry on this AI reports that a compatible representation is
AI_RC4BER. That AI provides the BER-encoded algorithm identifier for the RC4
algorithm. Look up the Reference Manual Chapter 4 entry for
B_GetAlgorithmInfo.
This function takes three arguments: an address for Crypto-C to deposit a pointer to
the
info
, the algorithm object from which we are getting the
info
and the info type.
The Reference Manual Chapter 2 entry on
AI_RC4BER tells us that the
info
returned by
B_GetAlgorithmInfo is a pointer to an ITEM. The type ITEM is defined in aglobal.h as:
We will declare a variable to be a pointer to an ITEM and use its address as the
info
argument. The prototype calls for the address of a
POINTER, not the address of a
pointer to an
ITEM, so type casting is necessary.
typedef struct {
unsigned char *data;
unsigned int len;
} ITEM;