pack PKCS7 structure

This commit is contained in:
Jacob Barthelmeh 2018-02-08 14:32:38 -07:00
parent c2f660c0fc
commit 7143b09786
2 changed files with 43 additions and 46 deletions

View File

@ -16464,13 +16464,13 @@ int pkcs7encrypted_test(void)
PKCS7Attrib attribs[] =
{
{ genAttrOid, sizeof(genAttrOid), genAttr, sizeof(genAttr) }
{ genAttrOid, genAttr, sizeof(genAttrOid), sizeof(genAttr) }
};
PKCS7Attrib multiAttribs[] =
{
{ genAttrOid, sizeof(genAttrOid), genAttr, sizeof(genAttr) },
{ genAttrOid2, sizeof(genAttrOid2), genAttr2, sizeof(genAttr2) }
{ genAttrOid, genAttr, sizeof(genAttrOid), sizeof(genAttr) },
{ genAttrOid2, genAttr2, sizeof(genAttrOid2), sizeof(genAttr2) }
};
#endif /* NO_AES */
@ -16638,12 +16638,12 @@ static int pkcs7signed_run_vectors(byte* rsaCert, word32 rsaCertSz,
PKCS7Attrib attribs[] =
{
{ transIdOid, sizeof(transIdOid),
transId, sizeof(transId) - 1 }, /* take off the null */
{ messageTypeOid, sizeof(messageTypeOid),
messageType, sizeof(messageType) },
{ senderNonceOid, sizeof(senderNonceOid),
senderNonce, sizeof(senderNonce) }
{ transIdOid, transId, sizeof(transIdOid),
sizeof(transId) - 1 }, /* take off the null */
{ messageTypeOid, messageType, sizeof(messageTypeOid),
sizeof(messageType) },
{ senderNonceOid, senderNonce, sizeof(senderNonceOid),
sizeof(senderNonce) }
};
const pkcs7SignedVector testVectors[] =

View File

@ -77,63 +77,60 @@ enum Pkcs7_Misc {
typedef struct PKCS7Attrib {
byte* oid;
word32 oidSz;
byte* value;
word32 oidSz;
word32 valueSz;
} PKCS7Attrib;
typedef struct PKCS7DecodedAttrib {
byte* oid;
word32 oidSz;
byte* value;
word32 valueSz;
struct PKCS7DecodedAttrib* next;
byte* oid;
byte* value;
word32 oidSz;
word32 valueSz;
} PKCS7DecodedAttrib;
typedef struct PKCS7 {
byte* content; /* inner content, not owner */
word32 contentSz; /* content size */
int contentOID; /* PKCS#7 content type OID sum */
byte issuerHash[KEYID_SIZE]; /* hash of all alt Names */
byte issuerSn[MAX_SN_SZ]; /* singleCert's serial number */
byte publicKey[MAX_RSA_INT_SZ + MAX_RSA_E_SZ ];/*MAX RSA key size (m + e)*/
word32 certSz[MAX_PKCS7_CERTS];
WC_RNG* rng;
int hashOID;
int encryptOID; /* key encryption algorithm OID */
int keyWrapOID; /* key wrap algorithm OID */
int keyAgreeOID; /* key agreement algorithm OID */
PKCS7Attrib* signedAttribs;
byte* content; /* inner content, not owner */
byte* singleCert; /* recipient cert, DER, not owner */
byte* issuer; /* issuer name of singleCert */
byte* privateKey; /* private key, DER, not owner */
void* heap; /* heap hint for dynamic memory */
byte* cert[MAX_PKCS7_CERTS];
word32 certSz[MAX_PKCS7_CERTS];
byte* singleCert; /* recipient cert, DER, not owner */
word32 singleCertSz; /* size of recipient cert buffer, bytes */
byte issuerHash[KEYID_SIZE]; /* hash of all alt Names */
byte* issuer; /* issuer name of singleCert */
word32 issuerSz; /* length of issuer name */
byte issuerSn[MAX_SN_SZ]; /* singleCert's serial number */
word32 issuerSnSz; /* length of serial number */
byte publicKey[MAX_RSA_INT_SZ + MAX_RSA_E_SZ ];/*MAX RSA key size (m + e)*/
word32 publicKeySz;
word32 publicKeyOID; /* key OID (RSAk, ECDSAk, etc) */
byte* privateKey; /* private key, DER, not owner */
word32 privateKeySz; /* size of private key buffer, bytes */
PKCS7Attrib* signedAttribs;
word32 signedAttribsSz;
/* Encrypted-data Content Type */
byte* encryptionKey; /* block cipher encryption key */
PKCS7Attrib* unprotectedAttribs; /* optional */
PKCS7DecodedAttrib* decodedAttrib; /* linked list of decoded attribs */
/* Enveloped-data optional ukm, not owner */
byte* ukm;
word32 ukmSz;
/* Encrypted-data Content Type */
byte* encryptionKey; /* block cipher encryption key */
word32 encryptionKeySz; /* size of key buffer, bytes */
PKCS7Attrib* unprotectedAttribs; /* optional */
word32 unprotectedAttribsSz;
PKCS7DecodedAttrib* decodedAttrib; /* linked list of decoded attribs */
word32 encryptionKeySz; /* size of key buffer, bytes */
word32 unprotectedAttribsSz;
word32 contentSz; /* content size */
word32 singleCertSz; /* size of recipient cert buffer, bytes */
word32 issuerSz; /* length of issuer name */
word32 issuerSnSz; /* length of serial number */
word32 publicKeySz;
word32 publicKeyOID; /* key OID (RSAk, ECDSAk, etc) */
word32 privateKeySz; /* size of private key buffer, bytes */
word32 signedAttribsSz;
int contentOID; /* PKCS#7 content type OID sum */
int hashOID;
int encryptOID; /* key encryption algorithm OID */
int keyWrapOID; /* key wrap algorithm OID */
int keyAgreeOID; /* key agreement algorithm OID */
} PKCS7;