CryptoSys PKI Pro Manual

RNG_TestDRBGVS

Test the RNG for conformance to NIST SP800-90A using the relevant test specified in DRBGVS.

VBA/VB6 Syntax

Public Declare Function RNG_TestDRBGVS Lib "diCrPKI.dll" (ByVal strOutput As String, ByVal nMaxChars As Long, ByVal nReturnedBitsLen As Long, ByVal strEntropyInput As String, ByVal strNonce As String, ByVal strPersonalizationString As String, ByVal strAdditionalInput1 As String, ByVal strEntropyReseed As String, ByVal strAdditionalInputReseed As String, ByVal strAdditionalInput2 As String, ByVal nOptions As Long) As Long

nRet = RNG_TestDRBGVS(strOutput, nMaxChars, nReturnedBitsLen, strEntropyInput, strNonce, strPersonalizationString, strAdditionalInput1, strEntropyReseed, strAdditionalInputReseed, strAdditionalInput2, nOptions)

C/C++ Syntax

long __stdcall RNG_TestDRBGVS(char *szOutput, long nMaxChars, long nReturnedBitsLen, const char *szEntropyInput, const char *szNonce, const char *szPersonalizationString, const char *szAdditionalInput1, const char *szEntropyReseed, const char *szAdditionalInputReseed, const char *szAdditionalInput2, long nOptions);

Parameters

szOutput
[out] to receive the ReturnedBits in hexadecimal format.
nMaxChars
[in] specifying the maximum number of hexadecimal characters to be received.
nReturnedBitsLen
[in] specifying the number of bits to be returned from each call to the generate function in the test.
szEntropyInput
[in] containing the EntropyInput value in hex format.
szNonce
[in] containing the Nonce value in hex format.
szPersonalizationString
[in] containing the PersonalizationString value in hex format.
szAdditionalInput1
[in] containing the first AdditionalInput value in hex format.
szEntropyReseed
[in] containing the EntropyReseed value in hex format.
szAdditionalInputReseed
[in] containing the AdditionalInputReseed value in hex format.
szAdditionalInput2
[in] containing the second AdditionalInput value in hex format.
nOptions
[in] Option flags: not used in this release. Specify zero.

Returns (VBA/C)

If successful, the return value is the number of characters in the output string; otherwise it returns a negative error code.

.NET Equivalent

Rng.TestDrbgvs Method

Python Equivalent

static Rng.test_drbgvs(returnedBitsLen, entropyInput, nonce, personalizationString, additionalInput1, entropyReseed, additionalInputReseed, additionalInput2)

Remarks

The test procedure, the input values and the expected output are described in the [DRBGVS] document and associated test vectors. The relevant DRBG mechanism is HMAC_DRBG SHA-512 without prediction resistance. Use the empty string "" to pass a zero-length input. All hex strings must have an even number of characters.

Example

' drbgtestvectors/drbgvectors_pr_false/HMAC_DRBG.txt (line 22654)
' # CAVS 14.3
' # DRBG800-90A information for "drbg_pr"
' # Generated on Tue Apr 02 15:32:12 2013
Dim nRet As Long
Dim strOutput As String
Dim nMaxChars As Long
' Set input values in hex
Const nReturnedBitsLen As Long = 2048
Const strEntropyInput As String = "da740cbc36057a8e282ae717fe7dfbb245e9e5d49908a0119c5dbcf0a1f2d5ab"
Const strNonce As String = "46561ff612217ba3ff91baa06d4b5440"
Const strPersonalizationString As String = "fc227293523ecb5b1e28c87863626627d958acc558a672b148ce19e2abd2dde4"
Const strAdditionalInput1 As String = "b7998998eaf9e5d34e64ff7f03de765b31f407899d20535573e670c1b402c26a"
Const strEntropyReseed As String = "1d61d4d8a41c3254b92104fd555adae0569d1835bb52657ec7fbba0fe03579c5"
Const strAdditionalInputReseed As String = "b9ed8e35ad018a375b61189c8d365b00507cb1b4510d21cac212356b5bbaa8b2"
Const strAdditionalInput2 As String = "2089d49d63e0c4df58879d0cb1ba998e5b3d1a7786b785e7cf13ca5ea5e33cfd"
Const strExpectedBits = "5b70f3e4da95264233efbab155b828d4e231b67cc92757feca407cc9615a6608" & _
	"71cb07ad1a2e9a99412feda8ee34dc9c57fa08d3f8225b30d29887d20907d123" & _
	"30fffd14d1697ba0756d37491b0a8814106e46c8677d49d9157109c402ad0c24" & _
	"7a2f50cd5d99e538c850b906937a05dbb8888d984bc77f6ca00b0e3bc97b16d6" & _
	"d25814a54aa12143afddd8b2263690565d545f4137e593bb3ca88a37b0aadf79" & _
	"726b95c61906257e6dc47acd5b6b7e4b534243b13c16ad5a0a1163c0099fce43" & _
	"f428cd27c3e6463cf5e9a9621f4b3d0b3d4654316f4707675df39278d5783823" & _
	"049477dcce8c57fdbd576711c91301e9bd6bb0d3e72dc46d480ed8f61fd63811"

' Print output details
Debug.Print "# HMAC_DRBG options: SHA-512"
Debug.Print "[SHA-512]"
Debug.Print "[PredictionResistance = False]"
Debug.Print "[EntropyInputLen = " & Len(strEntropyInput) * 8 / 2 & "]"
Debug.Print "[NonceLen = " & Len(strNonce) * 8 / 2 & "]"
Debug.Print "[PersonalizationStringLen = " & Len(strPersonalizationString) * 8 / 2 & "]"
Debug.Print "[AdditionalInputLen = " & Len(strAdditionalInput1) * 8 / 2 & "]"
Debug.Print
Debug.Print "COUNT = 0"
Debug.Print "EntropyInput = " & strEntropyInput
Debug.Print "Nonce = " & strNonce
Debug.Print "PersonalizationString = " & strPersonalizationString
Debug.Print "AdditionalInput = " & strAdditionalInput1
Debug.Print "EntropyInputReseed = " & strEntropyReseed
Debug.Print "AdditionalInputReseed = " & strAdditionalInputReseed
Debug.Print "AdditionalInput = " & strAdditionalInput2

' Perform the DRBGVS test, dimensioning output string first
strOutput = String(nReturnedBitsLen * 2 / 8, " ")
nRet = RNG_TestDRBGVS(strOutput, Len(strOutput), nReturnedBitsLen, strEntropyInput, strNonce, _
	strPersonalizationString, strAdditionalInput1, _
	strEntropyReseed, strAdditionalInputReseed, strAdditionalInput2, 0)
Debug.Print "ReturnedBits = " & strOutput
Debug.Print "ExpectedBits = " & strExpectedBits
Debug.Assert strOutput = strExpectedBits
# HMAC_DRBG options: SHA-512
[SHA-512]
[PredictionResistance = False]
[EntropyInputLen = 256]
[NonceLen = 128]
[PersonalizationStringLen = 256]
[AdditionalInputLen = 256]

COUNT = 0
EntropyInput = da740cbc36057a8e282ae717fe7dfbb245e9e5d49908a0119c5dbcf0a1f2d5ab
Nonce = 46561ff612217ba3ff91baa06d4b5440
PersonalizationString = fc227293523ecb5b1e28c87863626627d958acc558a672b148ce19e2abd2dde4
AdditionalInput = b7998998eaf9e5d34e64ff7f03de765b31f407899d20535573e670c1b402c26a
EntropyInputReseed = 1d61d4d8a41c3254b92104fd555adae0569d1835bb52657ec7fbba0fe03579c5
AdditionalInputReseed = b9ed8e35ad018a375b61189c8d365b00507cb1b4510d21cac212356b5bbaa8b2
AdditionalInput = 2089d49d63e0c4df58879d0cb1ba998e5b3d1a7786b785e7cf13ca5ea5e33cfd
ReturnedBits = 5b70f3e4da95264233efbab155b828d4e231b67cc92757feca407cc9615a6608...
ExpectedBits = 5b70f3e4da95264233efbab155b828d4e231b67cc92757feca407cc9615a6608...

See Also

RNG_Test

[Contents] [Index]

[PREV: RNG_Test...]   [Contents]   [Index]   
   [NEXT: RNG_UpdateSeedFile...]

Copyright © 2004-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-09-23T07:52:09Z.