Crypt-MatrixSSL3
view release on metacpan or search on metacpan
MatrixSSL3.xs view on Meta::CPAN
* Params:
* (in) ar - Perl scalar - holds the file name which contains multiple SCT (Signed Certificate
* Timestamp) binary structures received from CT server logs. This file repesents a ready
* to use extension data
* - Perl array rference - holds as elements file names of individual SCT binary structures
* received from CT server logs. The function will concatenate all these files and build
* the extension data
* (out) buffer - a pointer to a pointer that will be allocated and will hold the extension data
* (out) buffer_size - a pointer to an int32 variable that will hold the extension data size
*/
int build_SCT_buffer(SV *ar, unsigned char **buffer, int32 *buffer_size) {
#ifdef WIN32
struct _stat fstat;
#else
struct stat fstat;
#endif
AV *sct_array;
SV *item_sv;
unsigned char *item, *sct, *c;
STRLEN item_len = 0;
int sct_array_size = 0, i = 0, sct_total_size = 0, sct_size = 0, rc = PS_SUCCESS;
if (SvOK(ar)) {
if (!SvROK(ar)) {
/* a single file */
item = SvPV(ar, item_len);
#ifdef MATRIX_DEBUG
warn("Loading SCT single file: %s", item);
#endif
if (item == NULL)
croak("build_SCT_buffer: expecting a scalar or array reference as first parameter");
if ((rc = psGetFileBuf(NULL, item, buffer, buffer_size)) != PS_SUCCESS) {
warn("Error %d trying to read file %s", rc, item);
return rc;
}
return 1;
} else {
if (SvTYPE(SvRV(ar)) != SVt_PVAV)
croak("build_SCT_buffer: expecting a scalar or array reference as first parameter");
}
} else {
croak("build_SCT_buffer: expecting a scalar or array reference as first parameter");
}
/* get the SCT files array */
sct_array = (AV *) SvRV(ar);
/* get number of SCT files */
sct_array_size = (uint16) av_len(sct_array) + 1;
#ifdef MATRIX_DEBUG
warn("Preparing to read %d SCT files", sct_array_size);
#endif
for (i = 0; i < sct_array_size; i++) {
item_sv = *av_fetch(sct_array, i, 0);
item = SvPV(item_sv, item_len);
#ifdef WIN32
if (_stat(item, &fstat) != 0) {
#else
if (stat(item, &fstat) != 0) {
#endif
warn("Error reading stats for SCT file %s", item);
return -1;
}
#ifdef MATRIX_DEBUG
warn("Reading SCT file %d - %s; size: %d", i, item, fstat.st_size);
#endif
sct_total_size += (size_t) fstat.st_size;
}
sct_total_size += sct_array_size * 2;
*buffer_size = sct_total_size;
c = *buffer = (unsigned char *) psMallocNative(sct_total_size);
for (i = 0; i < sct_array_size; i++) {
item_sv = *av_fetch(sct_array, i, 0);
item = SvPV(item_sv, item_len);
if ((rc = psGetFileBuf(NULL, item, &sct, &sct_size)) != PS_SUCCESS) {
warn("Error %d trying to read file %s", rc, item);
psFreeNative(*buffer);
*buffer = NULL;
*buffer_size = 0;
return rc;
}
*c = (sct_size & 0xFF00) >> 8; c++;
*c = (sct_size & 0xFF); c++;
memcpy(c, sct, sct_size);
c+= sct_size;
psFreeNative(sct);
}
return sct_array_size;
}
MODULE = Crypt::MatrixSSL3 PACKAGE = Crypt::MatrixSSL3
INCLUDE: inc/const-xs.inc
PROTOTYPES: ENABLE
int _getObjCount()
CODE:
#ifdef MATRIX_DEBUG
RETVAL = objects;
#else
RETVAL = 0;
#endif
OUTPUT:
RETVAL
int set_cipher_suite_enabled_status(cipherId, status)
short cipherId;
int status;
( run in 0.653 second using v1.01-cache-2.11-cpan-39bf76dae61 )