| BN | Type (Structure)

rsa.h

typedef struct {

| unsigned char Len;

| unsigned char Data[];

} BN;

A structure for describing very large integers (up to 2040 bits).

Note that Data contains the number in little endian format.
TIOS uses big integers for implementing RSA criptography algorithm to authenticate (digitally sign) ROM images (and flash applications), more precise, to protect actual ROM/Flash certificate data (see cert.h header file). The basic ideas of RSA are as follows: under certain conditions, function
Y = (X ^ A) mod N
has function
X = (Y ^ B) mod N
as its inverse function, where parameter B depends, of course, of A and N. But, computing B from A and N requires that the prime factors of N are known. Now, suppose that N = P * Q, where P and Q are large primes, such that nobody can factor N in a real time. Suppose also that somebody (person XXX for example) knows two large primes P and Q. Person XXX can compute N = P * Q. After this, he may insist (for security reasons) that anybody which wants to send the message to XXX must to encode the message using the formula Y = (X^A) mod N, where X is an original message, and Y is encoded message. Constants A and N may be published without any danger, and pair (N,A) is so-called public key. XXX may decrypt encoded message Y using the formula X = (Y^B) mod N because XXX can calculate B (he knows the prime factor of N). But note that nobody else can decrypt X, because nobody else knows prime factors of N a priori, and they can not be computed in a real time. Pair (N,B) is so-called private key.
This is only a half of the story. Suppose that person XXX wants to send a message to person YYY. He will encrypt the message with the public key of person YYY. YYY will, of course, decrypt the message with his private key. But, suppose that XXX send together with encoded message another message (called "signature") which is encoded using formula Y = (X^B) mod N, i.e. using PRIVATE key of XXX. Then, if YYY tries to decode such message using PUBLIC key of XXX, he must get original message too (so, he will receive two identical copies of the message). But, after this, YYY can be sure that really XXX sent the message (not some third person), because nobody else can compute B from A, i.e. nobody else can produce a message which can be decrypted using the public key of XXX!
To summarize: the RSA algorithm uses two keys, one is public and one private. Data encrypted with one of these keys can only be decrypted with the other key. So given the procedure is secure, data encryped with the public key can only be decrypted with the private key, and valid data decrypted with the public key could only be produced by the private key.