Exemple #1
0
/**
 * xmlSecBase64CtxUpdate:
 * @ctx:                the pointer to #xmlSecBase64Ctx structure
 * @in:                 the input buffer
 * @inSize:             the input buffer size
 * @out:                the output buffer
 * @outSize:            the output buffer size
 *
 * Encodes or decodes the next piece of data from input buffer.
 *
 * Returns: the number of bytes written to output buffer or
 * -1 if an error occurs.
 */
int
xmlSecBase64CtxUpdate(xmlSecBase64CtxPtr ctx,
                     const xmlSecByte *in, xmlSecSize inSize,
                     xmlSecByte *out, xmlSecSize outSize) {
    xmlSecSize inResSize = 0, outResSize = 0;
    int ret;

    xmlSecAssert2(ctx != NULL, -1);
    xmlSecAssert2(in != NULL, -1);
    xmlSecAssert2(out != NULL, -1);

    if(ctx->encode != 0) {
        ret = xmlSecBase64CtxEncode(ctx, in, inSize, &inResSize,
                                    out, outSize, &outResSize);
        if((ret < 0) || (inResSize != inSize)) {
            xmlSecInternalError("xmlSecBase64CtxEncode", NULL);
            return(-1);
        }
    } else {
        ret = xmlSecBase64CtxDecode(ctx, in, inSize, &inResSize,
                                    out, outSize, &outResSize);
        if((ret < 0) || (inResSize != inSize)) {
            xmlSecInternalError("xmlSecBase64CtxDecode", NULL);
            return(-1);
        }
    }

    return(outResSize);
}
Exemple #2
0
/**
 * xmlSecBase64CtxUpdate:
 * @ctx: 		the pointer to #xmlSecBase64Ctx structure
 * @in:			the input buffer
 * @inSize: 		the input buffer size
 * @out: 		the output buffer
 * @outSize: 		the output buffer size
 *
 * Encodes or decodes the next piece of data from input buffer.
 * 
 * Returns the number of bytes written to output buffer or 
 * -1 if an error occurs.
 */
int
xmlSecBase64CtxUpdate(xmlSecBase64CtxPtr ctx,
		     const xmlSecByte *in, xmlSecSize inSize, 
		     xmlSecByte *out, xmlSecSize outSize) {
    xmlSecSize inResSize = 0, outResSize = 0;
    int ret;
    
    xmlSecAssert2(ctx != NULL, -1);
    xmlSecAssert2(in != NULL, -1);
    xmlSecAssert2(out != NULL, -1);

    if(ctx->encode != 0) {
	ret = xmlSecBase64CtxEncode(ctx, in, inSize, &inResSize, 
				    out, outSize, &outResSize);
	if((ret < 0) || (inResSize != inSize)) {
	    xmlSecErr_a_ignorar5(XMLSEC_ERRORS_HERE, 
			NULL,
			"xmlSecBase64CtxEncode",
			XMLSEC_ERRORS_R_XMLSEC_FAILED,
			XMLSEC_ERRORS_NO_MESSAGE);
    	    return(-1);
	}
    } else {
	ret = xmlSecBase64CtxDecode(ctx, in, inSize, &inResSize, 
				    out, outSize, &outResSize);
	if((ret < 0) || (inResSize != inSize)) {
	    xmlSecErr_a_ignorar5(XMLSEC_ERRORS_HERE, 
			NULL,
			"xmlSecBase64CtxDecode",
			XMLSEC_ERRORS_R_XMLSEC_FAILED,
			XMLSEC_ERRORS_NO_MESSAGE);
    	    return(-1);
	}
    }

    return(outResSize);
}