forked from wolfSSL/wolfssl
ASN: tidy up SetAsymKeyDerPublic()
Also, nighlty PowerPC Jenkins test complained of use of uninitialized in function. Ensure vars initialized despite not needing it.
This commit is contained in:
@ -20288,7 +20288,9 @@ static int SetAsymKeyDerPublic(const byte* pubKey, word32 pubKeyLen,
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#ifndef WOLFSSL_ASN_TEMPLATE
|
#ifndef WOLFSSL_ASN_TEMPLATE
|
||||||
word32 idx = 0, bitStringSz, algoSz, sz = 0;
|
word32 idx = 0;
|
||||||
|
word32 seqDataSz = 0;
|
||||||
|
word32 sz;
|
||||||
#else
|
#else
|
||||||
int sz = 0;
|
int sz = 0;
|
||||||
DECL_ASNSETDATA(dataASN, edPubKeyASN_Length);
|
DECL_ASNSETDATA(dataASN, edPubKeyASN_Length);
|
||||||
@ -20301,11 +20303,11 @@ static int SetAsymKeyDerPublic(const byte* pubKey, word32 pubKeyLen,
|
|||||||
#ifndef WOLFSSL_ASN_TEMPLATE
|
#ifndef WOLFSSL_ASN_TEMPLATE
|
||||||
/* calculate size */
|
/* calculate size */
|
||||||
if (withHeader) {
|
if (withHeader) {
|
||||||
algoSz = SetAlgoID(keyType, NULL, oidKeyType, 0);
|
word32 algoSz = SetAlgoID(keyType, NULL, oidKeyType, 0);
|
||||||
bitStringSz = SetBitString(pubKeyLen, 0, NULL);
|
word32 bitStringSz = SetBitString(pubKeyLen, 0, NULL);
|
||||||
|
|
||||||
sz = algoSz + bitStringSz + pubKeyLen;
|
seqDataSz = algoSz + bitStringSz + pubKeyLen;
|
||||||
sz += SetSequence(outLen, NULL);
|
sz = SetSequence(seqDataSz, NULL) + seqDataSz;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sz = pubKeyLen;
|
sz = pubKeyLen;
|
||||||
@ -20319,13 +20321,11 @@ static int SetAsymKeyDerPublic(const byte* pubKey, word32 pubKeyLen,
|
|||||||
/* headers */
|
/* headers */
|
||||||
if (ret == 0 && output != NULL && withHeader) {
|
if (ret == 0 && output != NULL && withHeader) {
|
||||||
/* sequence */
|
/* sequence */
|
||||||
idx = SetSequence(algoSz + bitStringSz + pubKeyLen, output);
|
idx = SetSequence(seqDataSz, output);
|
||||||
/* algo */
|
/* algo */
|
||||||
algoSz = SetAlgoID(keyType, output + idx, oidKeyType, 0);
|
idx += SetAlgoID(keyType, output + idx, oidKeyType, 0);
|
||||||
idx += algoSz;
|
|
||||||
/* bit string */
|
/* bit string */
|
||||||
bitStringSz = SetBitString(pubKeyLen, 0, output + idx);
|
idx += SetBitString(pubKeyLen, 0, output + idx);
|
||||||
idx += bitStringSz;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0 && output != NULL) {
|
if (ret == 0 && output != NULL) {
|
||||||
|
Reference in New Issue
Block a user