LibreOffice Module onlineupdate (master) 1
|
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <onlineupdate/mar_private.h>
#include <onlineupdate/mar.h>
#include "cryptox.h"
Go to the source code of this file.
Functions | |
int | mar_read_entire_file (const char *filePath, uint32_t maxSize, const uint8_t **data, uint32_t *size) |
int | mar_extract_and_verify_signatures_fp (FILE *fp, CryptoX_ProviderHandle provider, CryptoX_PublicKey *keys, uint32_t keyCount) |
Extracts each signature from the specified MAR file, then calls mar_verify_signatures_for_fp to verify each signature. More... | |
int | mar_verify_signatures_for_fp (FILE *fp, CryptoX_ProviderHandle provider, CryptoX_PublicKey *keys, const uint8_t *const *extractedSignatures, uint32_t signatureCount, uint32_t *numVerified) |
Verifies a MAR file by verifying each signature with the corresponding certificate. More... | |
int | ReadAndUpdateVerifyContext (FILE *fp, void *buffer, uint32_t size, CryptoX_SignatureHandle *ctxs, uint32_t count, const char *err) |
Reads the specified number of bytes from the file pointer and stores them in the passed buffer. More... | |
int | mar_verify_signatures (MarFile *mar, const uint8_t *const *certData, const uint32_t *certDataSizes, uint32_t certCount) |
Verifies a MAR file by verifying each signature with the corresponding certificate. More... | |
int mar_extract_and_verify_signatures_fp | ( | FILE * | fp, |
CryptoX_ProviderHandle | provider, | ||
CryptoX_PublicKey * | keys, | ||
uint32_t | keyCount | ||
) |
Extracts each signature from the specified MAR file, then calls mar_verify_signatures_for_fp to verify each signature.
fp | An opened MAR file handle |
provider | A library provider |
keys | The public keys to use to verify the MAR |
keyCount | The number of keys pointed to by keys |
Definition at line 194 of file mar_verify.c.
References CryptoX_Error, CryptoX_Success, i, mar_verify_signatures_for_fp(), MAX_SIGNATURE_LENGTH, MAX_SIGNATURES, MAX_SIZE_OF_MAR_FILE, ntohl(), and SIGNATURE_BLOCK_OFFSET.
Referenced by mar_verify_signatures().
int mar_read_entire_file | ( | const char * | filePath, |
uint32_t | maxSize, | ||
const uint8_t ** | data, | ||
uint32_t * | size | ||
) |
int mar_verify_signatures | ( | MarFile * | mar, |
const uint8_t *const * | certData, | ||
const uint32_t * | certDataSizes, | ||
uint32_t | certCount | ||
) |
Verifies a MAR file by verifying each signature with the corresponding certificate.
That is, the first signature will be verified using the first certificate given, the second signature will be verified using the second certificate given, etc. The signature count must exactly match the number of certificates given, and all signature verifications must succeed.
mar | The file who's signature should be calculated |
certData | Pointer to the first element in an array of certificate data |
certDataSizes | Pointer to the first element in an array for size of the data stored |
certCount | The number of elements in certData and certDataSizes |
Definition at line 136 of file mar_verify.c.
References CryptoX_Failed, CryptoX_FreePublicKey, CryptoX_InitCryptoProvider, CryptoX_InvalidHandleValue, CryptoX_LoadPublicKey, CryptoX_ProviderHandle, CryptoX_PublicKey, MarFile_::fp, mar_extract_and_verify_signatures_fp(), and MAX_SIGNATURES.
Referenced by main(), and VerifyLoadedCert().
int mar_verify_signatures_for_fp | ( | FILE * | fp, |
CryptoX_ProviderHandle | provider, | ||
CryptoX_PublicKey * | keys, | ||
const uint8_t *const * | extractedSignatures, | ||
uint32_t | signatureCount, | ||
uint32_t * | numVerified | ||
) |
Verifies a MAR file by verifying each signature with the corresponding certificate.
That is, the first signature will be verified using the first certificate given, the second signature will be verified using the second certificate given, etc. The signature count must exactly match the number of certificates given, and all signature verifications must succeed.
fp | An opened MAR file handle |
provider | A library provider |
keys | A pointer to the first element in an array of keys. |
extractedSignatures | Pointer to the first element in an array of extracted signatures. |
signatureCount | The number of signatures in the MAR file |
numVerified | Out parameter which will be filled with the number of verified signatures. This information can be useful for printing error messages. |
Definition at line 335 of file mar_verify.c.
References BLOCKSIZE, CryptoX_Error, CryptoX_Failed, CryptoX_FreeSignatureHandle, CryptoX_SignatureHandle, CryptoX_Success, CryptoX_VerifyBegin, CryptoX_VerifySignature, CryptoX_VerifyUpdate, i, MAX_SIGNATURE_LENGTH, MAX_SIGNATURES, ntohl(), ReadAndUpdateVerifyContext(), and SIGNATURE_BLOCK_OFFSET.
Referenced by mar_extract_and_verify_signatures_fp().
int ReadAndUpdateVerifyContext | ( | FILE * | fp, |
void * | buffer, | ||
uint32_t | size, | ||
CryptoX_SignatureHandle * | ctxs, | ||
uint32_t | count, | ||
const char * | err | ||
) |
Reads the specified number of bytes from the file pointer and stores them in the passed buffer.
fp | The file pointer to read from. |
buffer | The buffer to store the read results. |
size | The number of bytes to read, buffer must be at least of this size. |
ctxs | Pointer to the first element in an array of verify context. |
count | The number of elements in ctxs |
err | The name of what is being written to in case of error. |
Definition at line 89 of file mar_verify.c.
References count, CryptoX_Error, CryptoX_Failed, CryptoX_Success, CryptoX_VerifyUpdate, err, and size.
Referenced by mar_verify_signatures_for_fp().