bbtoolsapi.h 4.48 KB
#include <stdio.h>
#include <stdlib.h>
#ifndef WIN32
#include <netinet/in.h>
#else
#include <winsock2.h>
#endif

#include <PR/bbtypes.h>
#include <PR/bcp.h>
#include <PR/bbvirage.h>
#include <PR/bbmetadata.h>
#include <PR/bbticket.h>
#include <PR/bbcert.h>
#include <PR/bbnand.h>

#define SIZE_RSA_CERTBLOB_WORDS 228
#define SIZE_BB_CERTBLOB_WORDS 179

/* location of boot app key in virage constants blob */
#define BB_VIRAGE2_BOOTAPPKEY_LOC (21)
/* 
 * to generate virage2 data blob 
 */

int generateVirage2Data(u32 *constantsFile, 
                   u32 constantsFileLen, 
                   u32 bbID, 
                   BbEccPrivateKey privateKey,
                   BbEccPublicKey publicKey,
                   u32 *rand, 
                   void *viragePtr);
/* 
 * get Certificate for BB : create data in file format required
 */

int generateUnsignedBbCert(u32 certificateType, 
                           u32 sigType, 
                           u32 timestamp, 
                           u8 * subjectname, 
                           u8 * issuername, 
                           BbEccPrivateKey privatekey, 
                           u32 *ecccert,
                           int sizeofblob);

/* 
 * get RSA certs : create data in file format required.
 */
int generateUnsignedRSACert(u32 certificateType, 
                            u32 sigType, 
                            u32 timestamp, 
                            u8 * subjectname, 
                            u8 * issuername, 
                            u32 *publicKey, 
                            u32 exponent, 
                            u32 *rsacert,
                            int sizeofblob);
/* 
 * create content meta data blob
 */
/* 
 * create unsigned  meta data blob: called by content publishing 
 */


/* 
 * create unsigned  meta data blob: called by content publishing 
 */
  
int generateUnsignedContentMetaDataHead( 
                                    u32 caCrlVersion,
                                    u32 cpCrlVersion,

                                    BbContentId contentId, 
                                    u32 contentSize, 
                                    u32 descFlags, /* is it common encryption
                                                    use BB_CMD_DESC_COMMON_KEY*/
                                    u8 * commonIv, /* if we want 
                                                      common encryption */
                                    u32 *constantsFile, /* this is to get
                                                           the virage 
                                                           constants file
                                                           and get common key
                                                        */
                                    u8 * contentKey, 
                                    u8 * contentHash,
                                    u8 * contentIv,
                                    /* make this opaque to the server:7 words */
                                    u32 * contentProperties,
                                    /*
                                    
                                    u32 loadAddress, 
                                    u32 romOffset,
                                    u32 bootLength, 
                                    u32 execFlags, 
                                    u32 hwAccessRights, 
                                    u32 secureKernelRights,
                                    u32 sizeState, 
                                    */

                                    u32 bbid, /* optional to attach to one BB*/
                                    BbContentMetaDataHead *metadata);

        
int generateUnsignedEncryptedTicket( BbContentMetaData *metadata,
                                     BbId bbid,
                                     BbTicketId tid,
				     u16 limitCode,
				     u16 limit,
                                     u32 tsCrlVersion, 
                                     BbAesIv cmdIv, 
                                     BbEccPrivateKey serverprivateKey,
                                     BbEccPublicKey serverpublicKey,
                                     BbEccPublicKey bbpublicKey,
                                     BbTicket *ticket);   

int generateCrlHeader(u32 versionNumber, 
		      u32 type,
                      u32 unusedArg,
		      u32 date, 
		      BbServerName issuer, 
		      u32 numberRevoked, 
		      u32 sigType, 
		      u32 *crlHeaderBlob, 
		      u32 *lengthBlob);