FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/asn.c
/* Remove PKCS8 header, place inOutIdx at beginning of traditional,
 * return traditional length on success, negative on error */
Remove PKCS8 header, place inOutIdx at beginning of traditional,
return traditional length on success, negative on error
Remove PKCS8 header place inOutIdx at beginning of traditional return traditional length on success negative on error
int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, word32 sz,
                           word32* algId)
{
    word32 idx;
    int    version, length;
    int    ret;
    byte   tag;
    if (input == NULL || inOutIdx == NULL)
        return BAD_FUNC_ARG;
    idx = *inOutIdx;
    if (GetSequence(input, &idx, &length, sz) < 0)
        return ASN_PARSE_E;
    if (GetMyVersion(input, &idx, &version, sz) < 0)
        return ASN_PARSE_E;
    if (GetAlgoId(input, &idx, algId, oidKeyType, sz) < 0)
        return ASN_PARSE_E;
    if (GetASNTag(input, &idx, &tag, sz) < 0)
        return ASN_PARSE_E;
    idx = idx - 1; 
    if (tag == ASN_OBJECT_ID) {
        if (SkipObjectId(input, &idx, sz) < 0)
            return ASN_PARSE_E;
    }
    ret = GetOctetString(input, &idx, &length, sz);
    if (ret < 0) {
        if (ret == BUFFER_E)
            return ASN_PARSE_E;
        WOLFSSL_MSG("Couldn't find Octet string");
    }
    *inOutIdx = idx;
    return length;
}
int ToTraditionalInline_ex ( const byte * input , word32 * inOutIdx , word32 sz , word32 * algId ) { word32 idx ; int version , length ; int ret ; byte tag ; if ( input == NULL || inOutIdx == NULL ) return BAD_FUNC_ARG ; idx = * inOutIdx ; if ( GetSequence ( input , & idx , & length , sz ) < 0 ) return ASN_PARSE_E ; if ( GetMyVersion ( input , & idx , & version , sz ) < 0 ) return ASN_PARSE_E ; if ( GetAlgoId ( input , & idx , algId , oidKeyType , sz ) < 0 ) return ASN_PARSE_E ; if ( GetASNTag ( input , & idx , & tag , sz ) < 0 ) return ASN_PARSE_E ; idx = idx - 1 ; if ( tag == ASN_OBJECT_ID ) { if ( SkipObjectId ( input , & idx , sz ) < 0 ) return ASN_PARSE_E ; } ret = GetOctetString ( input , & idx , & length , sz ) ; if ( ret < 0 ) { if ( ret == BUFFER_E ) return ASN_PARSE_E ; WOLFSSL_MSG ( " " ) ; } * inOutIdx = idx ; return length ; }
Remove PKCS8 header, place inOutIdx at beginning of traditional,
 return traditional length on success, negative on error
Remove PKCS8 header place inOutIdx at beginning of traditional return traditional length on success negative on error
/* reset idx after finding tag */ /* Some private keys don't expect an octet string */