TrustCore SDK NanoCrypto API reference  version 7.0
srp.h File Reference

Header file for declaring Secure Remote Protocol methods. More...

Go to the source code of this file.

Functions

MOC_EXTERN MSTATUS SRP_computeVerifier (MOC_ASYM(hwAccelDescr hwAccelCtx) const ubyte *salt, ubyte4 saltLen, const ubyte *uname, ubyte4 unameLen, const ubyte *pw, ubyte4 pwLen, ubyte4 bitNum, ubyte **verifier, ubyte4 *verifierLen)
 Computes the verifier for a user. More...
 
MOC_EXTERN MSTATUS SRP_getGroupParameters (ubyte4 bitNum, vlong **modulus, vlong **generator, vlong **k)
 Gets the SRP Group parameters. More...
 
MOC_EXTERN MSTATUS SRP_getGroupParameters2 (ubyte4 bitNum, const ubyte **modulus, sbyte4 *modulusLen, const ubyte **generator, sbyte4 *generatorLen, const ubyte **k)
 Gets the SRP Group parameters in Big Endian byte array form. More...
 

Detailed Description

Header file for declaring Secure Remote Protocol methods.

To enable the methods in this file please define:

  • __ENABLE_MOCANA_SRP__

srp.h

Function Documentation

◆ SRP_computeVerifier()

MOC_EXTERN MSTATUS SRP_computeVerifier ( MOC_ASYM(hwAccelDescr hwAccelCtx) const ubyte *  salt,
ubyte4  saltLen,
const ubyte *  uname,
ubyte4  unameLen,
const ubyte *  pw,
ubyte4  pwLen,
ubyte4  bitNum,
ubyte **  verifier,
ubyte4 *  verifierLen 
)

Computes the verifier for a user. This is dependent on the user's username and password, and the user's random salt. Memory will be allocated for a buffer to hold the verifier. Be sure to free this buffer when done with it.

Parameters
saltThe user's randomly generated salt.
saltLenThe length of the salt in bytes.
unameThe username as a byte array.
unameLenThe length of the username in bytes.
pwThe user's password as a byte array.
pwLenThe length of the user's password in bytes.
bitNumThe bit size for the group requested. The acceptable values are 2048, 3072, 4096, 6144, and 8192. If + __MOCANA_MIN_SRP_BITS__ is defined to 1024, or 1536 then those sizes are also acceptable.
verifierPointer to the location that will receive the verifier as a newly allocated byte array.
verifierLenContents will be set to the length of the verifier in bytes.

To enable this method please define:

  • __ENABLE_MOCANA_SRP__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ SRP_getGroupParameters()

MOC_EXTERN MSTATUS SRP_getGroupParameters ( ubyte4  bitNum,
vlong **  modulus,
vlong **  generator,
vlong **  k 
)

Gets the SRP Group parameters, which are fixed groups dependent on the bit size requested. This method will allocate three elements. Be sure to call VLONG_freeVlong on each when done with them.

Parameters
bitNumThe bit size requested. The acceptable values are 2048, 3072, 4096, 6144, and 8192. If + __MOCANA_MIN_SRP_BITS__ is defined to 1024, or 1536 then those sizes are also acceptable.
modulusPointer to the location of the modulus for the bit size requested.
generatorPointer to the location of the group generator for the bit size requested.
kPointer to the location of the k parameter (a SHA1 hash dependent on the modulus and generator).

To enable this method please define:

  • __ENABLE_MOCANA_SRP__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ SRP_getGroupParameters2()

MOC_EXTERN MSTATUS SRP_getGroupParameters2 ( ubyte4  bitNum,
const ubyte **  modulus,
sbyte4 *  modulusLen,
const ubyte **  generator,
sbyte4 *  generatorLen,
const ubyte **  k 
)

Gets the SRP Group parameters, which are fixed groups dependent on the bit size requested. This method will get them in Big Endian byte array form. This method does not allocate any memeory.

Parameters
bitNumThe bit size requested. The acceptable values are 2048, 3072, 4096, 6144, and 8192. If + __MOCANA_MIN_SRP_BITS__ is defined to 1024, or 1536 then those sizes are also acceptable.
modulusContents will be set to the location of the modulus for the bit size requested.
modulusLenContents will be set to the size of the modulus in bytes.
generatorContents will be set to the location of the group generator for the bit size requested.
generatorLenContents will be set to the size of the group generator in bytes.
kContents will be set to the location of the k parameter (a SHA1 hash dependent on the modulus and generator). The size of k in bytes is always 20.

To enable this method please define:

  • __ENABLE_MOCANA_SRP__
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.