RSA Security Projection Television 5.2.2 Manuel d'utilisateur

Naviguer en ligne ou télécharger Manuel d'utilisateur pour Manuels des logiciels RSA Security Projection Television 5.2.2. RSA Security Projection Television 5.2.2 User's Manual Manuel d'utilisatio

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 376
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs

Résumé du contenu

Page 1 - Crypto-C

RSA BSAFE®Crypto-CCryptographic Components for CDeveloper’s GuideVersion 5.2.2

Page 2 - First printing: May 2001

x RSA BSAFE Crypto-C Developer’s GuideAppendix A Command-Line Demos 327Overview of the Demos . . . . . . . . . . . . . . . . . . . . . . . . . . .

Page 3 - Contents

Cryptography Overview78 RSA BSAFE Crypto-C Developer’s GuidePhase 1The first party randomly generates a private value, a number k1, greater than 0 but

Page 4 - Cryptography 35

Chapter 3 Cryptography 79Cryptography OverviewFigure 3-13 Elliptic Curve Diffie-Hellman Key AgreementThe MathEven though the two parties involved are

Page 5

Cryptography Overview80 RSA BSAFE Crypto-C Developer’s GuideR2: 2nd party’s public valuexS: secret keyIn phase 1, each party computes a private value,

Page 6 - Using Crypto-C 101

Chapter 3 Cryptography 81Cryptography OverviewFigure 3-14 Secret Sharing — Key Share AssignmentFigure 3-15 Secret Sharing — Full Key Generation From

Page 7

Cryptography Overview82 RSA BSAFE Crypto-C Developer’s GuideKey ManagementThe term key management refers to the collection of processes and methods fo

Page 8 - Public-Key Operations 213

Chapter 3 Cryptography 83Applications of CryptographyASCII Encoding and DecodingASCII encoding and decoding is required when you need to send encrypt

Page 9 - Secret Sharing Operations 305

Applications of Cryptography84 RSA BSAFE Crypto-C Developer’s Guide• Ensure file integrity and protect against tampering. Cryptographic techniques can

Page 10 - Index 349

Chapter 3 Cryptography 85Applications of Cryptography4. Perform the encryption and decryption using the RC4 cipher with the established key. If the a

Page 11 - List of Figures

Applications of Cryptography86 RSA BSAFE Crypto-C Developer’s Guidepublic key is communicated to the server and an entry is made in the table maintain

Page 12

Chapter 3 Cryptography 87Choosing AlgorithmsChoosing AlgorithmsIn some cases, an application’s constraints determine the algorithm. In other cases, t

Page 13 - List of Tables

xiList of Figures Figure 3-1 Symmetric-Key Encryption and Decryption . . . . . . . . . . . . . . . . . . . . 36 Figure 3-2 Triple DES Encryption a

Page 14

Choosing Algorithms88 RSA BSAFE Crypto-C Developer’s GuideBlock Symmetric-Key AlgorithmsThe following considerations may help when choosing between DE

Page 15

Chapter 3 Cryptography 89Choosing AlgorithmsDigital envelopes are more convenient when the contact between nodes is not interactive, such as email. O

Page 16 - What’s New in Version 5.2.2?

Choosing Algorithms90 RSA BSAFE Crypto-C Developer’s Guidelimited. In typical applications of cryptography, public-key operations are employed in comb

Page 17 - Organization of This Manual

Chapter 3 Cryptography 91Security Considerationsalready in place, or where a hardware developer wants to be able to provide a platform that supports

Page 18

Security Considerations92 RSA BSAFE Crypto-C Developer’s Guidethat ensure allocation of core memory, and not of virtual memory.It is a good idea to ge

Page 19 - Terms and Abbreviations

Chapter 3 Cryptography 93Security Considerationsattacker can predict two or three of the bits in each seed byte. Bit 7, for instance, will always be

Page 20 - Related Documents

Security Considerations94 RSA BSAFE Crypto-C Developer’s GuideInitialization Vectors and SaltsAlthough IVs and salts are not secret information, it is

Page 21

Chapter 3 Cryptography 95Security ConsiderationsStream CiphersA stream cipher (such as the RC4 cipher) will create a stream of pseudo-random bytes ba

Page 22 - How to Contact RSA Security

Security Considerations96 RSA BSAFE Crypto-C Developer’s Guideparameters, then in theory, an attacker with access to accurate timings can determine un

Page 23 - Introduction

Chapter 3 Cryptography 97Security Considerations = (r-1)(r)(md) = (1)(md) mod nCrypto-C offers bo

Page 24 - The Crypto-C Toolkit

xii RSA BSAFE Crypto-C Developer’s Guide

Page 25 - Hardware Support

Security Considerations98 RSA BSAFE Crypto-C Developer’s GuideTable 3-4 gives a summary of the recommended key sizes for the algorithms supported in C

Page 26 - NIST Standards and Crypto-C

Chapter 3 Cryptography 99Security Considerationsprogress in factoring algorithms and improvements in computing power.Diffie-Hellman Parameters and DS

Page 27 - PKCS Compared with NIST

Security Considerations100 RSA BSAFE Crypto-C Developer’s GuideElliptic Curve KeysFor prototyping and evaluation, RSA Security recommends setting the

Page 28

101Chapter 4Using Crypto-CAlgorithms in Crypto-CWhatever algorithm Crypto-C performs, it does so from an algorithm object. An algorithm object is used

Page 29 - Quick Start

Algorithms in Crypto-C102 RSA BSAFE Crypto-C Developer’s GuideInformation Formats Provided by Crypto-CThere are four types of AIs in Crypto-C. These A

Page 30 - The Six-Step Sequence

Chapter 4 Using Crypto-C 103Algorithms in Crypto-CPEM-Based Algorithm Info TypesThe Privacy Enhanced Mail (PEM) draft standard is a product of the In

Page 31 - Introductory Example

Algorithms in Crypto-C104 RSA BSAFE Crypto-C Developer’s GuideNote: Not all message digests are recommended. See “Message Digests” on page 47 for deta

Page 32

Chapter 4 Using Crypto-C 105Algorithms in Crypto-CAI_RC4WithMAC RC4 with message authentication code aAI_RC4WithMAC_BER RC4 with message authenticati

Page 33 - Chapter 2 Quick Start 11

Algorithms in Crypto-C106 RSA BSAFE Crypto-C Developer’s GuideAI_DESX_CBCPadBER DESX-CBC, 8-byte IV, BER-encoded algorithm identifierPKCS #5 aAI_DESX_

Page 34

Chapter 4 Using Crypto-C 107Algorithms in Crypto-CAI_MD2WithRC2_CBCPadBER MD2 digest followed by RC2-CBC, BER-encoded algorithm identifierPKCS #5 aAI

Page 35 - Chapter 2 Quick Start 13

xiiiList of TablesTable 3-1 Calculation of 827 mod 55. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54Table 3-2 Elliptic Curve

Page 36

Algorithms in Crypto-C108 RSA BSAFE Crypto-C Developer’s GuideAI_PKCS_OAEP_RSAPrivateBER RSA private-key encryption/decryption with OAEP in accordance

Page 37 - Chapter 2 Quick Start 15

Chapter 4 Using Crypto-C 109Algorithms in Crypto-CDigital Signatures Composite operations for signing data: digest the data, then encrypt the BER enc

Page 38

Algorithms in Crypto-C110 RSA BSAFE Crypto-C Developer’s GuideTable 4-9 Diffie-Hellman Key AgreementAlgorithm Info Type Description BERParameter Gener

Page 39 - Chapter 2 Quick Start 17

Chapter 4 Using Crypto-C 111Algorithms in Crypto-CElliptic Curve DSAAI_EC_DSA Raw ECDSA signature/verificationAI_EC_DSAWithDigest SHA1 digest followe

Page 40

Algorithms in Crypto-C112 RSA BSAFE Crypto-C Developer’s GuideTable 4-13 Advanced Encryption Standard (AES)Algorithm Info Type DescriptionAI_AES_CBC A

Page 41

Chapter 4 Using Crypto-C 113Keys In Crypto-CKeys In Crypto-CThe key object is used to hold any key-related information and to supply this information

Page 42

Keys In Crypto-C114 RSA BSAFE Crypto-C Developer’s GuideKI_RC2_BSAFE1 RC2 key in BSAFE 1.x formatKI_RC2WithBSAFE1Params RC2 key with additional parame

Page 43 - Chapter 2 Quick Start 21

Chapter 4 Using Crypto-C 115Keys In Crypto-CTable 4-18 Elliptic Curve KeysKey Information Type DescriptionKI_ECPrivate EC private key and underlying

Page 44 - Putting It All Together

System Considerations In Crypto-C116 RSA BSAFE Crypto-C Developer’s GuideSystem Considerations In Crypto-CAlgorithm ChoosersWhen you use an AI, it in

Page 45

Chapter 4 Using Crypto-C 117System Considerations In Crypto-CRC5, or RSA encryption. So we could have built an algorithm chooser that included only o

Page 46

xiv RSA BSAFE Crypto-C Developer’s Guide

Page 47 - Chapter 2 Quick Start 25

System Considerations In Crypto-C118 RSA BSAFE Crypto-C Developer’s Guidedescription of AI_X962Random_V0 instead of AI_SHA1Random:Note: The previous a

Page 48

Chapter 4 Using Crypto-C 119System Considerations In Crypto-CChapter 1 also gives the form that a surrender function must have:If you define a surren

Page 49

System Considerations In Crypto-C120 RSA BSAFE Crypto-C Developer’s GuideA routine that calls Crypto-C functions would use the above surrender functio

Page 50

Chapter 4 Using Crypto-C 121System Considerations In Crypto-Cobject. When you call B_GetAlgorithmState, you receive a buffer that contains all of the

Page 51 - Multiple Updates

System Considerations In Crypto-C122 RSA BSAFE Crypto-C Developer’s Guideinformation it is looking for. This information, though, belongs to Crypto-C;

Page 52

Chapter 4 Using Crypto-C 123System Considerations In Crypto-CSome applications may need to be completely autonomous; that is, they should have no nee

Page 53 - Chapter 2 Quick Start 31

System Considerations In Crypto-C124 RSA BSAFE Crypto-C Developer’s Guidemore individuals. For example, users may need to transmit a public key, ellip

Page 54 - Summary of the Six Steps

Chapter 4 Using Crypto-C 125System Considerations In Crypto-CCrypto-C returns a pointer to the location where we can find the info, not the info itse

Page 55

System Considerations In Crypto-C126 RSA BSAFE Crypto-C Developer’s GuideInput and OutputSome of the AI entries in the Reference Manual include the ca

Page 56

Chapter 4 Using Crypto-C 127System Considerations In Crypto-CCrypto-C offers padding for the symmetric block-encryption algorithms, which have no res

Page 57 - Cryptography

xvPrefaceDear Crypto-C Developer:Congratulations on your purchase of RSA BSAFE® Crypto-C (Crypto-C), the state-of-the-art in cryptographic software to

Page 58 - Cryptography Overview

System Considerations In Crypto-C128 RSA BSAFE Crypto-C Developer’s GuideThis applies to PKCS #1 v1.5 block 02 padding. Set OAEP or PKCS #12 OAEP have

Page 59 - Ciphers in Crypto-C

Chapter 4 Using Crypto-C 129System Considerations In Crypto-CKey SizeIn cryptography, security is measured in key size: the bigger the key, the great

Page 60 - Triple DES

System Considerations In Crypto-C130 RSA BSAFE Crypto-C Developer’s Guideends and the public exponent begins. It would be a good idea to put identifyi

Page 61 - • key size (in bytes)

Chapter 4 Using Crypto-C 131System Considerations In Crypto-C• Total: 484 bytesIn addition, when the most significant bit of the most significant byt

Page 62

Using Cryptographic Hardware132 RSA BSAFE Crypto-C Developer’s GuideUsing Cryptographic HardwareCrypto-C lets you enhance the security and speed of cr

Page 63 - Modes of Operation

Chapter 4 Using Crypto-C 133Using Cryptographic Hardwarethe application has been compiled. If more than one hardware method is present for the same A

Page 64

Using Cryptographic Hardware134 RSA BSAFE Crypto-C Developer’s GuidePKCS #11 SupportPKCS #11 support has been added to Crypto-C v5.1. The routine will

Page 65 - Cipher Feedback (CFB) Mode

Chapter 4 Using Crypto-C 135Using Cryptographic HardwareUsing a PKCS #11 Device with Crypto-CIf you want to have Crypto-C use a PKCS #11 device to pe

Page 66

Using Cryptographic Hardware136 RSA BSAFE Crypto-C Developer’s GuideIn this example, we passed 0 for sessionHandle and NULL_PTR for cryptokiFunctions.

Page 67 - Output Feedback (OFB) Mode

Chapter 4 Using Crypto-C 137Using Cryptographic Hardwaresurrender context (private key operations are more susceptible to a timing attack when you us

Page 68

What’s New in Version 5.2.2?xvi RSA BSAFE Crypto-C Developer’s GuideWhat’s New in Version 5.2.2?Following is a list of RSA BSAFE Crypto-C features tha

Page 69

Using Cryptographic Hardware138 RSA BSAFE Crypto-C Developer’s Guidewant to create a hardware chooser only, and if you want to do the task in hardware

Page 70

Chapter 4 Using Crypto-C 139Using Cryptographic HardwareThis AI has an associated info data struct that allows you to set attributes. See the Referen

Page 71

Using Cryptographic Hardware140 RSA BSAFE Crypto-C Developer’s Guidemay need to set the attributes manually for the token to work.You can use this AI

Page 72 - Public-Key Cryptography

Chapter 4 Using Crypto-C 141Using Cryptographic Hardwareinfo types if it is a key that resides on the token and is not private.Now you can send the p

Page 73

Using Cryptographic Hardware142 RSA BSAFE Crypto-C Developer’s GuideThis code looks just like regular code. Whether you are signing with software or h

Page 74 - MultiPrime Numbers

Chapter 4 Using Crypto-C 143Using Cryptographic Hardware CK_RV rv; CK_SESSION_HANDLE sessionHandle; HINSTANCE libHandle; GetFunctionList GetList

Page 75

Using Cryptographic Hardware144 RSA BSAFE Crypto-C Developer’s GuidePKCS #11 Support for DSA Key Pair GenerationThis section describes how to generate

Page 76 - Security

Chapter 4 Using Crypto-C 145Using Cryptographic HardwareNow that you have a key pair, extract the public key, part of the public key is a struct cont

Page 77 - Digital Envelopes

Using Cryptographic Hardware146 RSA BSAFE Crypto-C Developer’s Guidedestroying, or copy it into your own buffer. Since you generated the key pair only

Page 78 - Figure 3-10 Digital Envelope

Chapter 4 Using Crypto-C 147Using Cryptographic HardwareAdvanced PKCS #11This chapter earlier described internalKey as the collection of three items:

Page 79 - Chapter 3 Cryptography 57

Organization of This ManualPreface xviiV5.2. Use this AI to save the internal state of an RC4 encryption or decryption object, or to create a new ob

Page 80 - • A message

Using Cryptographic Hardware148 RSA BSAFE Crypto-C Developer’s GuideIn real life, you may never have to use this feature. Mostly you will retrieve the

Page 81 - Chapter 3 Cryptography 59

Chapter 4 Using Crypto-C 149Using Cryptographic HardwareTo implement this, the hardware accelerator might require you to call its key-wrapping routin

Page 83 - Digital Certificates

151Chapter 5Non-Cryptographic OperationsCrypto-C supplies a number of non-cryptographic algorithms that are necessary for cryptographic applications.

Page 84 - The Algorithm

Message Digests152 RSA BSAFE Crypto-C Developer’s GuideMessage DigestsA message digest is a fixed-length, statistically-unique identifier that corresp

Page 85 - Parameter Generation

Chapter 5 Non-Cryptographic Operations 153Message DigestsStep 3: InitTo initialize a message digest, call B_DigestInit. The Reference Manual Chapter

Page 86

Message Digests154 RSA BSAFE Crypto-C Developer’s GuideYour call will be the following:Step 5: FinalAn MD2 or MD5 digest is always 16 bytes; an SHA1 d

Page 87 - Elliptic Curve Cryptography

Chapter 5 Non-Cryptographic Operations 155Message DigestsStep 6: DestroyRemember to destroy all objects when you are done with them:BER-Encoding the

Page 88 - Elliptic Curve Parameters

Message Digests156 RSA BSAFE Crypto-C Developer’s GuideThe following example BER-encodes the preceeding sample digest:To decode BER-encoded informatio

Page 89 - Fields of Even Characteristic

Chapter 5 Non-Cryptographic Operations 157Message DigestsB_DigestUpdate before calling B_DigestFinal(). This is useful when an application is called

Page 90

Conventions Used in This Manualxviii RSA BSAFE Crypto-C Developer’s GuideConventions Used in This ManualThe following typographical conventions are us

Page 91 - The Point P and its Order

Message Digests158 RSA BSAFE Crypto-C Developer’s Guidestate of the algorithm object following the call to B_DigestUpdate. The digestAI argument is s

Page 92 - A Point of Prime Order

Chapter 5 Non-Cryptographic Operations 159Message DigestsTable 5-1 Code Sample: DigestDataSavedState() int DigestDataSavedState (ITEM *stateInfo, B_I

Page 93 - The Cofactor

Message Digests160 RSA BSAFE Crypto-C Developer’s GuideThis routine can be called until all of the data blocks have been digested. We can then restor

Page 94

Chapter 5 Non-Cryptographic Operations 161Hash-Based Message Authentication Code Hash-Based Message Authentication Code (HMAC)A hash-based message au

Page 95 - ECDSA Signature Scheme

Hash-Based Message Authentication Code (HMAC)162 RSA BSAFE Crypto-C Developer’s GuideStep 3: InitFor hash-based message authentication, you need a key

Page 96 - Verifying a Signature

Chapter 5 Non-Cryptographic Operations 163Hash-Based Message Authentication Code Once you have properly initialized the key object, you can call B_Di

Page 97

Hash-Based Message Authentication Code (HMAC)164 RSA BSAFE Crypto-C Developer’s GuideStep 5: FinalAfter the data to digest has been processed by calls

Page 98 -

Chapter 5 Non-Cryptographic Operations 165Generating Random NumbersGenerating Random NumbersIn the “Introductory Example” on page 9, we hard-coded th

Page 99

Generating Random Numbers166 RSA BSAFE Crypto-C Developer’s GuideStep 2: Setting The Algorithm ObjectYou need to supply an appropriate algorithm info

Page 100

Chapter 5 Non-Cryptographic Operations 167Generating Random NumbersRefer to “Saving State” on page 120 for a discussion of how to save the state of t

Page 101 - The Math

Terms and AbbreviationsPreface xixTerms and AbbreviationsThe following table lists terms and abbreviations used in this document. Refer to the Gloss

Page 102 - Secret Sharing

Generating Random Numbers168 RSA BSAFE Crypto-C Developer’s Guidepredict or reproduce. Once you have seeded the random algorithm, the algorithm can pr

Page 103 - Working with Keys

Chapter 5 Non-Cryptographic Operations 169Generating Random NumbersNow that you have a random seed, you can call B_RandomUpdate. The length argument

Page 104 - Key Escrow

Generating Random Numbers170 RSA BSAFE Crypto-C Developer’s GuideStep 6: DestroyRemember to destroy all objects when done with them. You must also cal

Page 105 - Applications of Cryptography

Chapter 5 Non-Cryptographic Operations 171Generating Random NumbersFor this example, you will specify six streams of randomness, and provide a seed s

Page 106 - Point-to-Point Applications

Converting Data Between Binary and ASCII172 RSA BSAFE Crypto-C Developer’s GuideConverting Data Between Binary and ASCIIIf you have data in binary for

Page 107 - Client/Server Applications

Chapter 5 Non-Cryptographic Operations 173Converting Data Between Binary and ASCIIStep 4: UpdateEnter the data to encode through B_EncodeUpdate. The

Page 108 - Peer-to-Peer Applications

Converting Data Between Binary and ASCII174 RSA BSAFE Crypto-C Developer’s GuideStep 5: FinalFinalize the encoding process, writing out any remaining

Page 109 - Choosing Algorithms

Chapter 5 Non-Cryptographic Operations 175Converting Data Between Binary and ASCIIStep 3: InitTo initialize decoding, call B_DecodeInit. This functio

Page 110

Converting Data Between Binary and ASCII176 RSA BSAFE Crypto-C Developer’s GuideStep 5: FinalFinalize the decoding process, writing out any bytes rema

Page 111 - Elliptic Curve Algorithms

177Chapter 6Symmetric-Key OperationsRecall that the RC4 algorithm of the “Introductory Example” on page 9 is called symmetric-key encryption because t

Page 112 - Interoperability

© 2001 RSA Security Inc. All rights reserved. 001-019003-522-001-000First printing: May 2001See our Web Site for regional Customer Service telephone a

Page 113 - Security Considerations

Related Documentsxx RSA BSAFE Crypto-C Developer’s GuideRelated DocumentsFollowing is a list of documents referenced in this book and suggested materi

Page 114 - Temporary Buffers

Block Ciphers178 RSA BSAFE Crypto-C Developer’s GuideBlock CiphersDES with CBCThe example in this section corresponds to the file descbc.c.Step 1: Cre

Page 115 - Choosing Passwords

Chapter 6 Symmetric-Key Operations 179Block CiphersencryptionMethodName is the block cipher that you will use; for this example, use “des”. The infor

Page 116 - DES Weak Keys

Block Ciphers180 RSA BSAFE Crypto-C Developer’s GuideYou must also indicate that you want to use the standard CBC padding which is defined in PKCS#5;

Page 117 - Timing Attacks and Blinding

Chapter 6 Symmetric-Key Operations 181Block CiphersStep 3b: Setting the Key ObjectYou want to use a KI compatible with DES encryption, so return to

Page 118 - · s mod n

Block Ciphers182 RSA BSAFE Crypto-C Developer’s GuideNow that you have a key, you need an algorithm chooser and a surrender context. This is a speedy

Page 119 - Choosing Key Sizes

Chapter 6 Symmetric-Key Operations 183Block CiphersStep 5: FinalStep 6: DestroyRemember to destroy all objects that you created and free up any memor

Page 120 - RSA Keys

Block Ciphers184 RSA BSAFE Crypto-C Developer’s GuideThe RC2 CipherThe RC2 cipher is a variable-key-size block cipher. Whereas a DES key requires eigh

Page 121 - Triple DES Keys

Chapter 6 Symmetric-Key Operations 185Block CiphersOnce again, encryptionMethodName is the block cipher that you will use; in this example, use “rc2”

Page 122 - Elliptic Curve Keys

Block Ciphers186 RSA BSAFE Crypto-C Developer’s GuideStep 3: InitYou need a key before you can initialize the algorithm object for encryption.Step 3a:

Page 123 - Using Crypto-C

Chapter 6 Symmetric-Key Operations 187Block CiphersUse a random number generator to come up with 24 bytes.It is a good idea to zeroize any sensitive

Page 124 - Basic Algorithm Info Types

Related DocumentsPreface xxi• Results from the RSA Factoring Challenge• Recommendations on Elliptic Curve Cryptosystems• Recent Results for MD2, MD4

Page 125 - Summary of AIs

Block Ciphers188 RSA BSAFE Crypto-C Developer’s GuideYou need an algorithm chooser and a surrender context. This is a speedy function, so it is reason

Page 126 - Table 4-3 ASCII Encoding

Chapter 6 Symmetric-Key Operations 189Block CiphersStep 5: FinalStep 6: DestroyRemember to destroy all objects created and free up any memory allocat

Page 127 - Symmetric Stream Ciphers

Block Ciphers190 RSA BSAFE Crypto-C Developer’s GuideDecryptingAs with the “Introductory Example” on page 9, decrypting is similar to encrypting. Use

Page 128

Chapter 6 Symmetric-Key Operations 191Block CiphersStep 2: Setting The Algorithm ObjectThere are a number of RC5 AIs from which to choose. Table 4-6

Page 129 - RSA Public-Key Cryptography

Block Ciphers192 RSA BSAFE Crypto-C Developer’s GuideStep 3: InitYou need a key before you can initialize the algorithm object for encryption. You wil

Page 130

Chapter 6 Symmetric-Key Operations 193Block CiphersUse a random number generator to create 10 bytes:It is a good idea to zeroize any sensitive data a

Page 131 - DSA Public-Key Cryptography

Block Ciphers194 RSA BSAFE Crypto-C Developer’s GuideNow that you have a key, you need an algorithm chooser and a surrender context. This is a speedy

Page 132 - Diffie-Hellman Key Agreement

Chapter 6 Symmetric-Key Operations 195Block CiphersStep 5: FinalStep 6: DestroyRemember to destroy all objects that you created and free up any memor

Page 133 - Hardware Interface

Block Ciphers196 RSA BSAFE Crypto-C Developer’s GuideDecryptingAs in the “Introductory Example” on page 9, decrypting is similar to encrypting. Use th

Page 134

Chapter 6 Symmetric-Key Operations 197Block Ciphersthat, as specified in the Reference Manual entry for AI_RC6_CBCPad, this AI requires an initialize

Page 135 - Keys In Crypto-C

How to Contact RSA Securityxxii RSA BSAFE Crypto-C Developer’s GuideHow to Contact RSA SecurityRSA Security Web SiteYou can visit the RSA Security Web

Page 136 - Block Cipher Keys

Block Ciphers198 RSA BSAFE Crypto-C Developer’s GuideStep 3: InitThe next step is to make a call to B_EncryptInit. To do this, you need a key object.

Page 137 - Token Keys

Chapter 6 Symmetric-Key Operations 199Block CiphersTo call B_EncryptInit, we also need an algorithm chooser. The Reference Manual entry for AI_RC6_C

Page 138 - Algorithm Choosers

Block Ciphers200 RSA BSAFE Crypto-C Developer’s Guidefor the surrender context:Step 5: FinalStep 6: DestroyRemember to destroy any objects that you cr

Page 139 - An RSA Algorithm Chooser

Chapter 6 Symmetric-Key Operations 201Block Ciphersbeen allocated:DecryptingAs in the “Introductory Example” on page 9, decrypting is similar to encr

Page 140 - The Surrender Context

Block Ciphers202 RSA BSAFE Crypto-C Developer’s GuideCBC mode requires an initialization vector, so assume that you have the following buffer containi

Page 141 - A Sample Surrender Function

Chapter 6 Symmetric-Key Operations 203Block CiphersStep 3a: Creating a Key ObjectStep 3b: Setting the Key DataNow you need to set the key size and pa

Page 142 - Saving State

Block Ciphers204 RSA BSAFE Crypto-C Developer’s GuideTo call B_EncryptInit, we also need an algorithm chooser. The Reference Manual entry for AI_AES_

Page 143 - When to Allocate Memory

Chapter 6 Symmetric-Key Operations 205Block CiphersStep 5: FinalStep 6: DestroyRemember to destroy any objects that you created and to free up any me

Page 144 - Memory-Management Routines

Block Ciphers206 RSA BSAFE Crypto-C Developer’s GuidePassword-Based EncryptionIn previous encryption methods, you used a random number generator to pr

Page 145 - BER/DER Encoding

Chapter 6 Symmetric-Key Operations 207Block CiphersStep 2: Setting The Algorithm ObjectThere are a number of PBE AIs from which to choose (see “Summa

Page 146

1Chapter 1IntroductionThis chapter introduces the Crypto-C toolkit. It lists the algorithms, cryptographic standards, NIST standards, and ANSI X9 stan

Page 147 - Chapter 4 Using Crypto-C 125

Block Ciphers208 RSA BSAFE Crypto-C Developer’s GuideStep 3: InitYou need a key before you can initialize the algorithm object for encryption. In PBE,

Page 148 - Input and Output

Chapter 6 Symmetric-Key Operations 209Block Cipherssecure; it is used for illustrative purposes only. It is not for duplication:You should zeroize an

Page 149 - The RSA Algorithm

Block Ciphers210 RSA BSAFE Crypto-C Developer’s GuideStep 4: UpdateEnter the data to encrypt through B_EncryptUpdate. The Reference Manual Chapter 2 e

Page 150 - General Considerations

Chapter 6 Symmetric-Key Operations 211Block CiphersStep 5: FinalStep 6: DestroyRemember to destroy all objects and free up any allocated memory:Decry

Page 152 - Private Key Size

213Chapter 7Public-Key OperationsIn public-key cryptography, two associated keys are necessary: one to encrypt, and the other to decrypt. The sender e

Page 153 - • Total: 484 bytes

Performing RSA Operations214 RSA BSAFE Crypto-C Developer’s GuidePerforming RSA OperationsThe RSA algorithm is a public-key algorithm that relies on t

Page 154 - Using Cryptographic Hardware

Chapter 7 Public-Key Operations 215Performing RSA OperationsStep 2: Setting the Algorithm ObjectFor this example, use AI_RSAKeyGen to generate an RSA

Page 155 - B_CreateSessionchooser is

Performing RSA Operations216 RSA BSAFE Crypto-C Developer’s GuideStep 3: InitLook up the description and prototype for B_GenerateInit in Chapter 4 of

Page 156 - PKCS #11 Support

Chapter 7 Public-Key Operations 217Performing RSA Operationsgenerates a candidate and tests to see if it is prime. If the candidate passes the test,

Page 157 - Chapter 4 Using Crypto-C 135

The Crypto-C Toolkit2 RSA BSAFE Crypto-C Developer’s GuideThe Crypto-C ToolkitCrypto-C provides developers with a state-of-the-art implementation of t

Page 158

MultiPrime218 RSA BSAFE Crypto-C Developer’s GuideMultiPrimeThis section provides an overview of the MulitPrime enhancement to Crypto-C including info

Page 159 - Chapter 4 Using Crypto-C 137

Chapter 7 Public-Key Operations 219MultiPrimeThis means 3-prime private operations can be about 38% faster than 2-prime operations. Or with 2-prime R

Page 160

MultiPrime220 RSA BSAFE Crypto-C Developer’s Guidedoes not allow you to generate an RSA key pair if the number of primes is more than three. Furthermo

Page 161 - Chapter 4 Using Crypto-C 139

Chapter 7 Public-Key Operations 221MultiPrimeB_ALGORITHM_METHOD *RSA_GEN_CHOOSER[] = { &AM_RSA_KEY_GEN, (B_ALGORITHM_METHOD *)NULL_PTR};A_RSA_M

Page 162

MultiPrime222 RSA BSAFE Crypto-C Developer’s GuideGenerating an RSA MultiPrime KeyRefer to the RSA_CreateMultiPrimeRSAKeypair routine defined in the s

Page 163 - Chapter 4 Using Crypto-C 141

Chapter 7 Public-Key Operations 223MultiPrimeStep 3: InitNow, make the appropriate adjustments to the algorithm chooser so that the algorithm methods

Page 164

MultiPrime224 RSA BSAFE Crypto-C Developer’s GuideCrypto-C FormatpublicKey is a key object that was set by the Crypto-C function B_GenerateKeypair. It

Page 165

Chapter 7 Public-Key Operations 225MultiPrimeis unique to Crypto-C. If the recipient is not using Crypto-C, how do you give that recipient the inform

Page 166

MultiPrime226 RSA BSAFE Crypto-C Developer’s Guidesend it off. Remember to free any memory you allocated:Note: The conversion into BER or DER is known

Page 167

Chapter 7 Public-Key Operations 227MultiPrimeinfo to B_SetAlgorithmInfo as NULL_PTR:Step 3: InitYou will encrypt using the recipient’s RSA public key

Page 168

Chapter 1 Introduction 3The Crypto-C ToolkitPublic-Key Algorithms• RSA Public Key Cryptosystem• Diffie-Hellman Key AgreementDigital Signatures• DSA•

Page 169 - Advanced PKCS #11

MultiPrime228 RSA BSAFE Crypto-C Developer’s GuideYou are encrypting 8 bytes, so you do not need to worry about that constraint. However, the output o

Page 170 - Hardware Issues

Chapter 7 Public-Key Operations 229MultiPrimeStep 6: DestroyWhen you are done with all your objects, remember to destroy them.RSA Private-Key Decrypt

Page 171 - Chapter 4 Using Crypto-C 149

MultiPrime230 RSA BSAFE Crypto-C Developer’s GuideStep 3: InitTo decrypt, you must use the RSA private key that is associated with the public key that

Page 172

Chapter 7 Public-Key Operations 231MultiPrimeStep 5: FinalStep 6: DestroyWhen you are done with all objects, remember to destroy them:Optimal Asymetr

Page 173 - Non-Cryptographic Operations

MultiPrime232 RSA BSAFE Crypto-C Developer’s Guideencrypt is usually 8, 16, or (for BER-encoded digests) 34 or 35. If you want to encrypt and decrypt

Page 174 - Message Digests

Chapter 7 Public-Key Operations 233MultiPrimeRSA Digital SignaturesThe section “Authentication and Digital Signatures” on page 57 discusses what a di

Page 175 - Step 4: Update

MultiPrime234 RSA BSAFE Crypto-C Developer’s GuideB_CreateAlgorithmObject:Step 2: Setting The Algorithm ObjectCrypto-C provides three methods for comp

Page 176 - Step 5: Final

Chapter 7 Public-Key Operations 235MultiPrimeentry for the AI in use:Note: If you want to sign using the blinding technique to thwart timing attacks

Page 177 - BER-Encoding the Digest

MultiPrime236 RSA BSAFE Crypto-C Developer’s Guidesurrender context outlined in “The Surrender Context” on page 118:Step 6: DestroyWhen you are done w

Page 178 - Saved State

Chapter 7 Public-Key Operations 237MultiPrimeB_CreateAlgorithmObject:Step 2: Setting The Algorithm ObjectThe signer should tell you which message dig

Page 179

Cryptographic Standards and Crypto-C4 RSA BSAFE Crypto-C Developer’s GuideCryptographic Standards and Crypto-CPKCS Standards and Crypto-CCrypto-C is a

Page 180 - B_SetAlgorithmInfo call

MultiPrime238 RSA BSAFE Crypto-C Developer’s GuideNote: If the algorithm object was not set to AI_MD5WithRSAEncryption, AI_MD2WithRSAEncryption, AI_SH

Page 181

Chapter 7 Public-Key Operations 239Performing DSA OperationsStep 6: DestroyWhen you are done with all objects, remember to destroy them:Performing DS

Page 182

Performing DSA Operations240 RSA BSAFE Crypto-C Developer’s Guideof info supplied to B_SetAlgorithmInfo is a pointer to the following:Crypto-C will ge

Page 183 - Code (HMAC)

Chapter 7 Public-Key Operations 241Performing DSA OperationsStep 5: GenerateTo generate DSA parameters, call the Crypto-C function B_GenerateParamete

Page 184

Performing DSA Operations242 RSA BSAFE Crypto-C Developer’s GuideGenerating a DSA Key PairThe previous code generated the DSA parameters and set an al

Page 185

Chapter 7 Public-Key Operations 243Performing DSA Operationscontains the AM for SHA1 random number generation. The last argument is the surrender con

Page 186 - Step 6: Destroy

Performing DSA Operations244 RSA BSAFE Crypto-C Developer’s GuideComputing a Digital SignatureStep 1: Creating An Algorithm ObjectDeclare a variable t

Page 187 - Generating Random Numbers

Chapter 7 Public-Key Operations 245Performing DSA Operationsproperly cast NULL_PTR for the surrender context:Step 4: UpdateDigest the data to sign wi

Page 188

Performing DSA Operations246 RSA BSAFE Crypto-C Developer’s Guidepage 118:Step 6: DestroyWhen you are done with all objects, remember to destroy them:

Page 189

Chapter 7 Public-Key Operations 247Performing DSA OperationsStep 2: Setting The Algorithm ObjectTo verify the signature created here, use the same AI

Page 190

Chapter 1 Introduction 5Cryptographic Standards and Crypto-C• Secure Hash Algorithm (SHA1), as specified in FIPS PUB 180-1, Secure Hash Standard (SHS

Page 191 - Step 5: Generate

Performing DSA Operations248 RSA BSAFE Crypto-C Developer’s Guidedata and you know its length, your call is the following:Step 5: FinalB_VerifyUpdate

Page 192 - Step 2: Set

Chapter 7 Public-Key Operations 249Performing Diffie-Hellman Key AgreementPerforming Diffie-Hellman Key AgreementDiffie-Hellman Key Agreement is a me

Page 193 - Steps 4, 5, 6

Performing Diffie-Hellman Key Agreement250 RSA BSAFE Crypto-C Developer’s GuideStep 2: Setting The Algorithm ObjectThere is only one AI for generating

Page 194 - Encoding Binary Data To ASCII

Chapter 7 Public-Key Operations 251Performing Diffie-Hellman Key AgreementStep 3: InitInitialize the generation process with B_GenerateInit. Build an

Page 195

Performing Diffie-Hellman Key Agreement252 RSA BSAFE Crypto-C Developer’s GuideThe second is a result algorithm object. Crypto-C will generate some va

Page 196 - Decoding ASCII-Encoded Data

Chapter 7 Public-Key Operations 253Performing Diffie-Hellman Key AgreementDistributing Diffie-Hellman ParametersThe central authority, after computin

Page 197

Performing Diffie-Hellman Key Agreement254 RSA BSAFE Crypto-C Developer’s GuideIf you look at the elements of the struct:dhKeyAgreeParams->prime.da

Page 198

Chapter 7 Public-Key Operations 255Performing Diffie-Hellman Key AgreementCrypto-C returns a pointer to where that information resides, not the infor

Page 199 - Symmetric-Key Operations

Performing Diffie-Hellman Key Agreement256 RSA BSAFE Crypto-C Developer’s GuideDiffie-Hellman Key AgreementIf you are one of the parties involved in t

Page 200 - Block Ciphers

Chapter 7 Public-Key Operations 257Performing Diffie-Hellman Key AgreementStep 3: InitInitialize the algorithm object with B_KeyAgreeInit. The Refere

Page 201

Cryptographic Standards and Crypto-C6 RSA BSAFE Crypto-C Developer’s GuideANSI X9 Standards and Crypto-CCrypto-C also complies with a number of standa

Page 202

Performing Diffie-Hellman Key Agreement258 RSA BSAFE Crypto-C Developer’s GuideThe fourth is the size of the buffer you allocated; if the buffer is no

Page 203 - Cipher KIs

Chapter 7 Public-Key Operations 259Performing Diffie-Hellman Key Agreementparties might only need eight bytes for a session key. If that is the case,

Page 204

Performing Elliptic Curve Operations260 RSA BSAFE Crypto-C Developer’s GuidePerforming Elliptic Curve OperationsElliptic curve cryptosystems can be us

Page 205 - Decrypting

Chapter 7 Public-Key Operations 261Performing Elliptic Curve OperationsThe second, ecParamsObj, is set and initialized by B_GenerateParameters; it wi

Page 206 - The RC2 Cipher

Performing Elliptic Curve Operations262 RSA BSAFE Crypto-C Developer’s Guideversion number; in Crypto-C, the only version available is 0. The second a

Page 207

Chapter 7 Public-Key Operations 263Performing Elliptic Curve OperationsStep 3: InitYou can pass a NULL_PTR for the surrender context, because B_Gener

Page 208

Performing Elliptic Curve Operations264 RSA BSAFE Crypto-C Developer’s GuideStep 5: Generate This function may take a while, so you should use a surre

Page 209

Chapter 7 Public-Key Operations 265Performing Elliptic Curve OperationsThe Reference Manual Chapter 2 entry for AI_ECParameters also states that the

Page 210

Performing Elliptic Curve Operations266 RSA BSAFE Crypto-C Developer’s GuideThe following procedure, AllocAndCopyECParamInfo, is an example of an appl

Page 211

Chapter 7 Public-Key Operations 267Performing Elliptic Curve OperationsFor this example application, use AllocAndCopyECParamInfo() to make a copy of

Page 212 - The RC5 Cipher

7Chapter 2Quick StartThis chapter provides an introduction to using Crypto-C. You are first presented with the Crypto-C model and then you are present

Page 213

Performing Elliptic Curve Operations268 RSA BSAFE Crypto-C Developer’s GuideIn the sample code, FreeECParamInfo is implemented as follows:Generating a

Page 214

Chapter 7 Public-Key Operations 269Performing Elliptic Curve OperationsStep 2: SetThe Reference Manual indicates that the appropriate AI to use for g

Page 215

Performing Elliptic Curve Operations270 RSA BSAFE Crypto-C Developer’s GuideStep 3: InitializeHere, you can pass a NULL_PTR for the surrender context,

Page 216

Chapter 7 Public-Key Operations 271Performing Elliptic Curve OperationsRetrieving an Elliptic Curve KeyIf you need to store or transport information

Page 217

Performing Elliptic Curve Operations272 RSA BSAFE Crypto-C Developer’s GuideB_GetKeyInfo gives a pointer to memory, but this memory is owned by Crypto

Page 218 - The RC6 Cipher

Chapter 7 Public-Key Operations 273Performing Elliptic Curve OperationsGenerating Acceleration TablesAn acceleration table stores precomputed version

Page 219

Performing Elliptic Curve Operations274 RSA BSAFE Crypto-C Developer’s GuideStep 1: CreateDeclare a variable to be B_ALGORITHM_OBJ. As defined in the

Page 220

Chapter 7 Public-Key Operations 275Performing Elliptic Curve OperationsThe first field in this structure, parameterInfoType, is used to interpret the

Page 221

Performing Elliptic Curve Operations276 RSA BSAFE Crypto-C Developer’s GuideStep 5: FinalStep 5a: Allocate memoryYou must allocate sufficient memory t

Page 222

Chapter 7 Public-Key Operations 277Performing Elliptic Curve OperationsStep 6: DestroyYou must free all allocated memory and destroy all objects when

Page 223 - The AES Cipher

iiiContentsPreface xvWhat’s New in Version 5.2.2? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviImproved per

Page 224

The Six-Step Sequence8 RSA BSAFE Crypto-C Developer’s GuideThe Six-Step SequenceThe Crypto-C model generally follows a six-step sequence:1. Create2. S

Page 225 - Step 3b: Setting the Key Data

Performing Elliptic Curve Operations278 RSA BSAFE Crypto-C Developer’s GuideOf course, you can write your own versions of these procedures to satisfy

Page 226

Chapter 7 Public-Key Operations 279Performing Elliptic Curve OperationsStep 3: InitTo initialize the proper algorithms, you must supply an algorithm

Page 227

Performing Elliptic Curve Operations280 RSA BSAFE Crypto-C Developer’s GuideStep 5b: Build the public-key acceleration tableIt can take a while to gen

Page 228 - Password-Based Encryption

Chapter 7 Public-Key Operations 281Performing Elliptic Curve OperationsTo initialize ecParamsObj with a set of parameters describing an elliptic curv

Page 229

Performing Elliptic Curve Operations282 RSA BSAFE Crypto-C Developer’s GuideBecause you have the EC parameters in the A_EC_PARAMS structure ecParams,

Page 230

Chapter 7 Public-Key Operations 283Performing Elliptic Curve OperationsYou must allocate space to hold the results of Phase 1 and Phase 2. The larges

Page 231

Performing Elliptic Curve Operations284 RSA BSAFE Crypto-C Developer’s GuideStep 5: Phase 2By the time you have reached this step, Alice and Bob have

Page 232

Chapter 7 Public-Key Operations 285Performing Elliptic Curve OperationsTo sign an arbitrarily long message with the elliptic curve version of DSA, yo

Page 233

Performing Elliptic Curve Operations286 RSA BSAFE Crypto-C Developer’s GuideAssume that the steps in “Generating an Elliptic Curve Key Pair” on page 2

Page 234

Chapter 7 Public-Key Operations 287Performing Elliptic Curve OperationsStep 2b (optional): Set Acceleration Table InfoGo through the steps in the sec

Page 235 - Public-Key Operations

Chapter 2 Quick Start 9Introductory ExampleIntroductory ExampleThe CD containing the Crypto-C library distribution also includes sample source code t

Page 236 - Performing RSA Operations

Performing Elliptic Curve Operations288 RSA BSAFE Crypto-C Developer’s GuideStep 4: UpdateNow, using B_SignUpdate, pass in the data to be signed:Step

Page 237

Chapter 7 Public-Key Operations 289Performing Elliptic Curve Operationsinitialized random algorithm in B_SignFinal:Step 6: DestroyDestroy all objects

Page 238

Performing Elliptic Curve Operations290 RSA BSAFE Crypto-C Developer’s GuideStep 2b (Optional): Set Public Key Acceleration Table InfoYou can use eith

Page 239

Chapter 7 Public-Key Operations 291Performing Elliptic Curve OperationsStep 6: DestroyDestroy all objects that are no longer needed:Performing ECDSA

Page 240 - MultiPrime

Performing Elliptic Curve Operations292 RSA BSAFE Crypto-C Developer’s GuideStep 2: Setting the Algorithm ObjectYou need to set the algorithm object t

Page 241 - How Many Primes?

Chapter 7 Public-Key Operations 293Performing Elliptic Curve OperationsGenerating an EC Key PairSee “Generating an Elliptic Curve Key Pair” on page 2

Page 242

Performing Elliptic Curve Operations294 RSA BSAFE Crypto-C Developer’s GuideStep 3: InitBuild an algorithm chooser with the appropriate AMs:Now associ

Page 243

Chapter 7 Public-Key Operations 295Performing Elliptic Curve OperationsStep 5: FinalFirst you must allocate space to store the signature. The output

Page 244 - Structure

Performing Elliptic Curve Operations296 RSA BSAFE Crypto-C Developer’s GuideVerifying a Digital SignatureTo verify the signature, you must go through

Page 245

Chapter 7 Public-Key Operations 297Performing Elliptic Curve OperationsStep 5: FinalPass in the signature that was received with the message. B_Veri

Page 246 - Crypto-C Format

Introductory Example10 RSA BSAFE Crypto-C Developer’s Guidespecify the type of algorithm that is being used, supply any special information or paramet

Page 247

Performing Elliptic Curve Operations298 RSA BSAFE Crypto-C Developer’s GuideUsing Elliptic Curve ParametersSee the section “Generating Elliptic Curve

Page 248 - RSA Public-Key Encryption

Chapter 7 Public-Key Operations 299Performing Elliptic Curve OperationsStep 1: CreateFirst, create the algorithm object that will hold the informatio

Page 249

Performing Elliptic Curve Operations300 RSA BSAFE Crypto-C Developer’s GuideStep 3: InitYou must initialize the algorithm object to perform encryptio

Page 250

Chapter 7 Public-Key Operations 301Performing Elliptic Curve Operations Step 5: FinalStep 6: DestroyDestroy all objects that are no longer needed. Al

Page 251 - RSA Private-Key Decryption

Performing Elliptic Curve Operations302 RSA BSAFE Crypto-C Developer’s GuideECAES Private-Key DecryptionThe steps for decryption are similar to those

Page 252

Chapter 7 Public-Key Operations 303Performing Elliptic Curve Operations Step 5: FinalStep 6: DestroyDestroy any objects that are no longer needed. Al

Page 254

305Chapter 8Secret Sharing OperationsSecret SharingSecret sharing allows a system to require a certain number of “shares” to retrieve a secret. The pr

Page 255 - RSA Digital Signatures

Secret Sharing306 RSA BSAFE Crypto-C Developer’s GuideThe example in this section corresponds to the file scrtshar.c.Step 1: Creating An Algorithm Obj

Page 256

Chapter 8 Secret Sharing Operations 307Secret SharingStep 4: UpdateCall B_EncryptUpdate once for each of the total number of shares. Each call to B_E

Page 257

Chapter 2 Quick Start 11Introductory ExampleStandard RSA Security coding practices use the above do-while construct to make it easy to break out of a

Page 258 - Verifying a Digital Signature

Secret Sharing308 RSA BSAFE Crypto-C Developer’s GuideStep 5: FinalFinalize the process with B_EncryptFinal. This function does not need a random algo

Page 259

Chapter 8 Secret Sharing Operations 309Secret SharingReconstructing the SecretTo reconstruct the secret, call B_DecryptUpdate for each share you are

Page 260

Secret Sharing310 RSA BSAFE Crypto-C Developer’s GuideStep 4: UpdateCall B_DecryptUpdate once for each of the shares you are using to reconstruct the

Page 261 - Performing DSA Operations

Chapter 8 Secret Sharing Operations 311Secret SharingStep 6: DestroyRemember to destroy all objects and free up any allocated memory when you are don

Page 263

313Chapter 9Putting It All Together: An X9.31 ExampleThe example in this chapter shows how to perform RSA digital signing and verifying according to t

Page 264 - Generating a DSA Key Pair

The X9.31 Sample Program314 RSA BSAFE Crypto-C Developer’s GuideThe X9.31 Sample Program#include <stdio.h>#include <string.h> #include &

Page 265 - DSA Signatures

Chapter 9 Putting It All Together: An X9.31 Example 315The X9.31 Sample ProgramGenerating Random BytesThe first thing the application must do is to g

Page 266 - Computing a Digital Signature

The X9.31 Sample Program316 RSA BSAFE Crypto-C Developer’s GuideTo create a random algorithm object and set the parameters: /* ===================

Page 267

Chapter 9 Putting It All Together: An X9.31 Example 317The X9.31 Sample ProgramProviding the SeedIn this example, the seed is provided by keyboard in

Page 268

Introductory Example12 RSA BSAFE Crypto-C Developer’s Guidethere is a single stream cipher, the RC4 cipher, and a number of AIs that can be used to im

Page 269

The X9.31 Sample Program318 RSA BSAFE Crypto-C Developer’s GuideGenerating a Key PairOnce you have the random bytes, you can use them to generate an R

Page 270

Chapter 9 Putting It All Together: An X9.31 Example 319The X9.31 Sample Program /* ======================================================== */

Page 271

The X9.31 Sample Program320 RSA BSAFE Crypto-C Developer’s GuideComputing a Digital SignatureNow you can use the key pair to compute a digital signatu

Page 272

Chapter 9 Putting It All Together: An X9.31 Example 321The X9.31 Sample Program• For digestMethodName, use "sha1"; currently this is the on

Page 273

The X9.31 Sample Program322 RSA BSAFE Crypto-C Developer’s Guide signVerifyParams.encryptionMethodName = (unsigned char *)"rsaSignX931";

Page 274

Chapter 9 Putting It All Together: An X9.31 Example 323The X9.31 Sample ProgramVerifying the SignatureVerifying an X9.31 RSA signature is almost iden

Page 275

The X9.31 Sample Program324 RSA BSAFE Crypto-C Developer’s Guide /* Step 4: Update */ if ((status = B_VerifyUpdate (digitalVerifier, (

Page 276 - BER Format

Chapter 9 Putting It All Together: An X9.31 Example 325The X9.31 Sample ProgramSurrendering ControlThe following function, included as part of x931.c

Page 277

The X9.31 Sample Program326 RSA BSAFE Crypto-C Developer’s GuidePrinting the Buffer ContentsThe following procedure prints the current contents of the

Page 278

327Appendix ACommand-Line DemosOverview of the DemosIn addition to the sample programs included on the CD, there are three Crypto-C command-line demo

Page 279 - Step 4: Phase 1

Chapter 2 Quick Start 13Introductory ExampleSee the description and prototype in Chapter 4 of the Reference Manual for B_EncryptInit:As in Step 2, th

Page 280 - Step 5: Phase 2

Command-Line Demo User’s Guide328 RSA BSAFE Crypto-C Developer’s Guide• BDEMOEC can use ECDSA to create and verify digital signatures for a file, and

Page 281 - Saving the Object State

Appendix A Command-Line Demos 329Command-Line Demo User’s Guide> bdemo -s < testinNotice that this uses ‘<’ to redirect testin as the input

Page 282

Command-Line Demo User’s Guide330 RSA BSAFE Crypto-C Developer’s Guide• the name and location of the file to be signed• the name of the file you want

Page 283

Appendix A Command-Line Demos 331Command-Line Demo User’s Guide• the name and location of the file that contains the encrypted data • the name and lo

Page 284

Command-Line Demo User’s Guide332 RSA BSAFE Crypto-C Developer’s GuideBDEMODSABDEMODSA demonstrates the use of DSA to digitally sign and verify the in

Page 285

Appendix A Command-Line Demos 333Command-Line Demo User’s GuideOnce a key pair has been generated, the following top-level menu is displayed:S - Sign

Page 286

Command-Line Demo User’s Guide334 RSA BSAFE Crypto-C Developer’s GuideBDEMOECBDEMOEC provides the same functionality as BDEMO, but uses elliptic curve

Page 287

Appendix A Command-Line Demos 335File ReferenceFile ReferenceThe C source code files for the demo programs provide a convenient means to learn Crypto

Page 288 - The following procedure

BSLite336 RSA BSAFE Crypto-C Developer’s GuideBSLiteBSLite is a collection of routines that interface with the Crypto-C library. BSLite demonstrates h

Page 289

Appendix A Command-Line Demos 337BSLiteA single C source file, bslite.c, with a single header file, bslite.h, contains the entire BSLite Code. For mo

Page 290

Introductory Example14 RSA BSAFE Crypto-C Developer’s Guideobject as an RC4 key, we need to use B_SetKeyInfo. See Chapter 4 of the Reference Manual fo

Page 292 - Step 3: Initialize

339GlossaryThis section lists security and cryptographic terms and abbreviations, along with their definitions, that are used throughout the RSA BSAFE

Page 293

340 RSA BSAFE Crypto-C Developer’s GuideAESAdvanced Encryption Standard.algorithmA series of steps used to complete a task.AliceThe name traditionally

Page 294

Glossary 341Data Encryption StandardSee DES.decryptionThe inverse (reverse) of encryption. The process by which the ciphertext is converted into pla

Page 295

342 RSA BSAFE Crypto-C Developer’s GuideECDSAElliptic Curve DSA (Digital Signature Algorithm). An elliptic curve analogue of DSA.EDIElectronic (busine

Page 296

Glossary 343identificationA process through which one ascertains the identity of another person or entity.keyA string of bits used widely in cryptog

Page 297

344 RSA BSAFE Crypto-C Developer’s GuideNISTNational Institute of Standards and Technology. A United States agency that produces security and cryptogr

Page 298

Glossary 345private keyIn public-key cryptography, this key is the secret key. It is primarily used for decryption but is also used for encryption w

Page 299

346 RSA BSAFE Crypto-C Developer’s Guidesecret sharingSplitting a secret (for examle, a private key) into many pieces such that any specified subset o

Page 300

Glossary 347verificationThe act of recognizing that a person or entity is who or what it claims to be.XORA binary bitwise operator yielding the resu

Page 301

Chapter 2 Quick Start 15Introductory ExampleNow we can complete the call to B_SetKeyInfo:As with algorithm objects, once you have set a key object, y

Page 303

349IndexAacceleration table 273Adelman, Leonard 52Advanced Encryption Standard xviiSee AESAdvanced PKCS #11 147AES xvii, 40, 41AI See algorithm info t

Page 304

350 RSA BSAFE Crypto-C Developer’s Guidecertificate See digital certificateCFB See modes of operationcharacteristic See elliptic curve cryptographycho

Page 305

Index 351elliptic curve cryptography 65–79algorithm info types 110curve generation 262examplesacceleration table 273–280key pair generation 268–270k

Page 306 - Step 5: Phase 2

352 RSA BSAFE Crypto-C Developer’s Guidekey (continued)RC2 39, 99RC4 87, 99RC5 99, 190recovery 89registering 61RSA 53, 54, 97, 98size 97, 98, 129token

Page 307 - Generating an EC Key Pair

Index 353Ppadding 37, 126, 180RSA algorithm 227parametersDiffie-Hellman key agreement 63, 99, 249Digital Signature Algorithm 60, 239surrender contex

Page 308

354 RSA BSAFE Crypto-C Developer’s GuideRSA Security Inc.FAQ 55Web site 48Ssalt 49, 94iterations 207sample program filesberder.c 124descbc.c 178dhagre

Page 309

Introductory Example16 RSA BSAFE Crypto-C Developer’s Guideinstructions on writing an algorithm chooser. For the purposes of our example, we see that

Page 310

Chapter 2 Quick Start 17Introductory Exampleinformation that it needs to perform RC4 encryption. In Step 4, we can enter the data to encrypt with the

Page 311

iv RSA BSAFE Crypto-C Developer’s GuideCryptographic Standards and Crypto-C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Page 312 - Step 3: Init

Introductory Example18 RSA BSAFE Crypto-C Developer’s GuideFor now, we declare:For a stream cipher, the length of the encrypted (output) data is equal

Page 313

Chapter 2 Quick Start 19Introductory Examplefunction must know the size of the buffer. The Update function will not attempt to place data into unallo

Page 314

Introductory Example20 RSA BSAFE Crypto-C Developer’s GuideFor our example, the first argument is rc4Encrypter. The second argument is a pointer to th

Page 315

Chapter 2 Quick Start 21Introductory Examplefunction calls after the do-while construct. That way, even if there is an error somewhere and the progra

Page 316

Introductory Example22 RSA BSAFE Crypto-C Developer’s GuideFor this example, call T_free as follows:Note: Using T_free means you can no longer access

Page 317

Chapter 2 Quick Start 23Introductory Example static char dataToEncrypt[] = "Encrypt this sentence."; unsigned char *encryptedData = NULL_

Page 318

Introductory Example24 RSA BSAFE Crypto-C Developer’s Guide /* Step 4: Update */ encryptedData = T_malloc (dataToEncryptLen); if ((status

Page 319 - Using ECAES

Chapter 2 Quick Start 25Introductory ExampleYou may find it a useful exercise to compile and link this program. Also, it could also be instructive to

Page 320 - ECAES Public-Key Encryption

Decrypting the Introductory Example26 RSA BSAFE Crypto-C Developer’s GuideDecrypting the Introductory ExampleDecrypting data is similar to encrypting.

Page 321

Chapter 2 Quick Start 27Decrypting the Introductory ExampleStep 3b: Setting the Key ObjectWe need to fill our key with the same 10 bytes of data we

Page 322

Contents vOptimal Asymmetric Encryption Padding (OAEP) . . . . . . . . . . . . . . . . . . . . . . . . . . .55Authentication and Digital Signatures

Page 323

Decrypting the Introductory Example28 RSA BSAFE Crypto-C Developer’s GuideStep 5: FinalIn the “Introductory Example” on page 9, the plaintext was a st

Page 324 - Step 4: Update

Chapter 2 Quick Start 29Multiple UpdatesMultiple UpdatesAn application can do multiple updates before the Final call. For example, suppose you have d

Page 325

Multiple Updates30 RSA BSAFE Crypto-C Developer’s Guideplaces them into the given buffer, and sets a flag indicating whether the bytes returned are th

Page 326

Chapter 2 Quick Start 31Multiple UpdatesIn the preceeding code example, we took dataToEncryptLen bytes of data to encrypt and passed them to B_Encryp

Page 327 - Secret Sharing Operations

Summary of the Six Steps32 RSA BSAFE Crypto-C Developer’s GuideSummary of the Six StepsA typical implementation uses the six steps as follows:Step 0:

Page 328

Chapter 2 Quick Start 33Summary of the Six Steps• For some algorithms, such as generating a public/private key pair, there is no Update step. Step 5:

Page 330

35Chapter 3Cryptography This chapter contains a brief outline of the basic cryptographic principles and terminology used throughout this manual and do

Page 331 - Reconstructing the Secret

Cryptography Overview36 RSA BSAFE Crypto-C Developer’s GuideCryptography OverviewSymmetric-Key CryptographyIn symmetric-key cryptography, as Figure 3-

Page 332

Chapter 3 Cryptography 37Cryptography OverviewBlock CiphersBlock ciphers encrypt data block-by-block. They can encrypt each block separately as in EC

Page 333

vi RSA BSAFE Crypto-C Developer’s GuideElliptic Curve Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Page 334

Cryptography Overview38 RSA BSAFE Crypto-C Developer’s GuideTriple DESTriple DES executes DES three times, which triples the number of bits in an encr

Page 335 - An X9.31 Example

Chapter 3 Cryptography 39Cryptography Overviewit is proprietary to RSA Security. The RC2 cipher has an eight-byte block size. Therefore, the input mu

Page 336 - The X9.31 Sample Program

Cryptography Overview40 RSA BSAFE Crypto-C Developer’s Guidefor 12-round RC5-32, recent cryptanalytic work suggests 16 rounds is now a more conservati

Page 337 - Generating Random Bytes

Chapter 3 Cryptography 41Cryptography Overviewwould slow down the encryption and decryption operations. In addition, if the 20-round version of RC6 i

Page 338

Cryptography Overview42 RSA BSAFE Crypto-C Developer’s GuideElectronic Codebook (ECB) ModeECB is not a feedback mode; it encrypts each block of input

Page 339 - Providing the Seed

Chapter 3 Cryptography 43Cryptography OverviewCipher Block Chaining (CBC) ModeWith CBC mode, each plaintext block is XORed with the previous cipherte

Page 340 - Generating a Key Pair

Cryptography Overview44 RSA BSAFE Crypto-C Developer’s Guide Figure 3-5 Cipher Feedback (CFB) ModeTo encrypt plaintext using CFB mode:1. Generate your

Page 341

Chapter 3 Cryptography 45Cryptography OverviewOutput Feedback (OFB) ModeOutput feedback mode is similar to CFB mode, except that the quantity XORed w

Page 342

Cryptography Overview46 RSA BSAFE Crypto-C Developer’s GuideFigure 3-6 Output Feedback Mode (OFB)Stream CiphersA stream cipher processes the input dat

Page 343

Chapter 3 Cryptography 47Cryptography Overviewguess), an attacker would be able to determine some of the original message bytes by XORing two sets of

Page 344

Contents viiMemory-Management Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122Memory-Management Rou

Page 345 - Verifying the Signature

Cryptography Overview48 RSA BSAFE Crypto-C Developer’s Guide• It is computationally infeasible to produce data that has a specific digest. In other wo

Page 346

Chapter 3 Cryptography 49Cryptography OverviewHash-Based Message Authentication Codes (HMAC)A hash-based message authentication code (HMAC) combines

Page 347 - Surrendering Control

Cryptography Overview50 RSA BSAFE Crypto-C Developer’s GuideNormally, the mixing is a message digest. This makes the task of getting from password to

Page 348 - Printing the Buffer Contents

Chapter 3 Cryptography 51Cryptography Overviewher message using that public key. Unlike symmetric-key cryptography, the key used for encryption will

Page 349 - Command-Line Demos

Cryptography Overview52 RSA BSAFE Crypto-C Developer’s Guideauthentication that MIT professors Ronald L. Rivest, Adi Shamir, and Leonard M. Adleman in

Page 350 - Starting BDEMO

Chapter 3 Cryptography 53Cryptography Overviewbelow. To compute ciphertext c from a plaintext message m, find c = me mod n. To decrypt, determine the

Page 351 - Using BDEMO

Cryptography Overview54 RSA BSAFE Crypto-C Developer’s GuideThe calculation is shown in Table 3-1:SummaryTake two large primes, p and q, and find thei

Page 352 - Open a File Envelope

Chapter 3 Cryptography 55Cryptography OverviewHowever, for very large numbers, factoring is very difficult. The RSA Laboratories publication, Frequen

Page 353 - Generate a Key Pair

Cryptography Overview56 RSA BSAFE Crypto-C Developer’s Guideto reveal the contents of a digital envelope. The main features of OAEP are redundancy and

Page 354 - BDEMODSA

Chapter 3 Cryptography 57Cryptography OverviewAuthentication and Digital SignaturesSuppose Alice and Bob are disputing a contract. Alice says that Bo

Page 355 - Sign a File

viii RSA BSAFE Crypto-C Developer’s GuideChapter 6 Symmetric-Key Operations 177Block Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . .

Page 356 - Using BDEMOEC

Cryptography Overview58 RSA BSAFE Crypto-C Developer’s Guide1. Alice and Bob compose a contract in digital format. The file can be in any form, such a

Page 357 - File Reference

Chapter 3 Cryptography 59Cryptography Overview4. Digest the message file.5. If the digest matches the 16 bytes you obtained from decrypting the origi

Page 358

Cryptography Overview60 RSA BSAFE Crypto-C Developer’s GuideDigital Signature Algorithm (DSA)The Digital Signature Algorithm (DSA) is part of the Digi

Page 359

Chapter 3 Cryptography 61Cryptography Overviewa = gu1 mod pb = yu2 mod pv = (a · b mod p) mod q3. If v = r, the signature is verified. If v ≠ r, the

Page 360

Cryptography Overview62 RSA BSAFE Crypto-C Developer’s GuideA certificate connects an entity to a public key. For instance, it can list an individual’

Page 361 - Glossary

Chapter 3 Cryptography 63Cryptography Overview• Phase 1• Phase 2Figure 3-12 The Diffie-Hellman Key Agreement ProtocolParameter GenerationA central au

Page 362

Cryptography Overview64 RSA BSAFE Crypto-C Developer’s Guide3. The two parties exchange the public values.These private and public values correspond t

Page 363

Chapter 3 Cryptography 65Cryptography OverviewSecurityThe security of Diffie-Hellman key agreement relies on the difficulty of computing nth roots mo

Page 364

Cryptography Overview66 RSA BSAFE Crypto-C Developer’s Guide• Elliptic Curve Signature Schemes (ECDSA)• Elliptic Curve Authenticated Encryption Scheme

Page 365

Chapter 3 Cryptography 67Cryptography Overview• An odd prime field, Fp, where p is an odd prime.• A field of even characteristic, F2m.For more inform

Page 366

Contents ixPerforming Diffie-Hellman Key Agreement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249Generating Diffie-Hellman Param

Page 367

Cryptography Overview68 RSA BSAFE Crypto-C Developer’s Guide0=0·I≡ (2·2m–1)·I mod2m= 2·(2m–1·I)≡ 2·1 mod 2m=2Instead, we create the field F2m in a com

Page 368

Chapter 3 Cryptography 69Cryptography Overviewelliptic curve parameters.Coefficients Over a Field of Even CharacteristicAn elliptic curve E over a fi

Page 369

Cryptography Overview70 RSA BSAFE Crypto-C Developer’s Guideis written E(Fq).The Order of an Elliptic CurveThe addition system that makes the points o

Page 370

Chapter 3 Cryptography 71Cryptography Overview• The order n of P P is sometimes called the base point.The CofactorWe mentioned previously that the pr

Page 371

Cryptography Overview72 RSA BSAFE Crypto-C Developer’s GuideRepresenting Fields of Even CharacteristicFor fields of even characteristic (fields of the

Page 372

Chapter 3 Cryptography 73Cryptography OverviewCreating the Key PairTo compute a public/private key pair:1. Generate a random value, d, between 1 and

Page 373

Cryptography Overview74 RSA BSAFE Crypto-C Developer’s Guide, you will be using regular arithmetic. This is so different from arithmetic in F2m that,

Page 374

Chapter 3 Cryptography 75Cryptography OverviewThe following calculations are really just a series of substitutions that can be made by looking back a

Page 375

Cryptography Overview76 RSA BSAFE Crypto-C Developer’s GuideEncrypting a Message Using the Public KeyAnyone who wishes to send Bob an encrypted messag

Page 376

Chapter 3 Cryptography 77Cryptography Overview6. Compute an authentication tag, tag = SHA1 (x1 || M’). That is, tag is the SHA1 hash of concatenation

Commentaires sur ces manuels

Pas de commentaire