Search Persits Software Knowledge Base

 

Article PS01041239

Numeric equivalents of constants defined by AspEncrypt type library

Problem Description

The AspEncrypt component's type library defines a number of constant identifiers (macros) that are to be used as arguments to various methods and properties. These constants designate various encryption algorithms, options, modes, etc. such as calgRC2 for RC2, calg3DES for Triple DES, etc. You must make sure these constants are properly defined, or use their numeric equivalents instead.

Solution

When AspEncrypt is used in VB, the AspEncrypt constants are automatically defined when you include Persits Software AspEncrypt in your project's References.

In the ASP environment, you must include the following tag in your code:

<!--METADATA TYPE="TypeLib" UUID="{B72DF063-28A4-11D3-BF19-009027438003}"-->

Otherwise these constans will be undefined, and will all evaluate to 0 which will cause errors such as

Invalid algorithm specified.

Invalid flags specified.

Certain other development environments are unable to retrieve the constants' numeric values from an object's type library. In this situation, you must not use the constant identifiers at all, and should replace them with their respective numeric equivalents. For example, instead of

Set key = Context.GenerateKeyFromPassword("pwd", calgSHA, calgRC4, 40)

you must write

Set key = Context.GenerateKeyFromPassword("pwd", 32772, 26625, 40)

The following table lists all constants and their numeric equivalents:

Constant Value
CryptoBlobTypes
cbtSimpleBlob 1
cbtPublicKeyBlob 6
cbtPrivateKeyBlob 7
cbtPlainTextBlob 8
CryptoCipherModes
ccmCBC 1
ccmECB 2
ccmOFB 3
ccmCFB 4
ccmCTS 5
CryptoCipherPadding
ccpPKCS5 1
ccpRandom 2
ccpZero 3
CryptoAlgorithms
catKeyExchange 1
catSignature 2
calgRC2 26114
calgRC4 26625
calgMD2 32769
calgMD4 32770
calgMD5 32771
calgSHA 32772
calgSHA256 32780
calgSHA384 32781
calgSHA512 32782
calgDES 26113
calg3DES 26115
calg3DES2 26121
calgAES128 26126
calgAES192 26127
calgAES256 26128

Related Articles

PS01032928 - Invalid flags specified/Invalid algorithm specified error when using strong encryption

Created: 2/8/2002 4:54:16 AM
Last Modified: 9/26/2005 1:21:19 PM

Copyright © Persits Software, Inc. 1998 - 2018
For technical support, write to support@persits.com.