Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

BigNum to byte stream

AArya2
New Contributor I
423 Views

I am implementing an SGX Attestation Service Provider using IPP Crypto.

I have derived a shared DH secret with the other party and now want to derive other keys from it using an AES CMAC.

The DH secret is stored in a BigNum while ippsAES_CMAC_UPDATE receives its input message through a pointer to a byte-stream.

Would just passing the BigNum pointer work? If not, is there another simple (preferably copy-free) way to get a pointer to a byte stream representing the number in little-endian format?

0 Kudos
1 Solution
Zhen_Z_Intel
Employee
423 Views

Dear customer,

You could use ippsGetOctString_BN to transfer big number to Ipp8u byte array. I am not sure which Big number class you are using, if you use IppsBigNumState type, there's no any problem.

But if you are using BigNumber, it is the class written by ourselves, source code are provided in appendix. I am afraid there's no exact sub-function for transferring BibNumber to String implemented in this class. Cause this class is only for setting bignumber & bignumber calculation. In the BigNumber class, the setting Bignumber function is actually use the same way of ippsSetOctString_BN. So, you'd better create IppsBigNumState type value by call NewIppBn, and then call ippsGetOctString_BN.

Or you could write a function by your self to split BigBumber string into 8 bits array(2 hex~1 byte). The BigNumber is actually an array that each element is 32*8bits. For more info, please refer to Big Number Arithmetic

Best regards,
Fiona

View solution in original post

0 Kudos
1 Reply
Zhen_Z_Intel
Employee
424 Views

Dear customer,

You could use ippsGetOctString_BN to transfer big number to Ipp8u byte array. I am not sure which Big number class you are using, if you use IppsBigNumState type, there's no any problem.

But if you are using BigNumber, it is the class written by ourselves, source code are provided in appendix. I am afraid there's no exact sub-function for transferring BibNumber to String implemented in this class. Cause this class is only for setting bignumber & bignumber calculation. In the BigNumber class, the setting Bignumber function is actually use the same way of ippsSetOctString_BN. So, you'd better create IppsBigNumState type value by call NewIppBn, and then call ippsGetOctString_BN.

Or you could write a function by your self to split BigBumber string into 8 bits array(2 hex~1 byte). The BigNumber is actually an array that each element is 32*8bits. For more info, please refer to Big Number Arithmetic

Best regards,
Fiona

0 Kudos
Reply