예제 #1
0
PyObject *xmlsec_KeyInfoCtxDebugDump(PyObject *self, PyObject *args) {
  PyObject *keyInfoCtx_obj, *output_obj;
  xmlSecKeyInfoCtxPtr keyInfoCtx;
  FILE *output;

  if (CheckArgs(args, "OF:keyInfoCtxDebugDump")) {
    if (!PyArg_ParseTuple(args, "OO:keyInfoCtxDebugDump",
			  &keyInfoCtx_obj, &output_obj))
      return NULL;
  }
  else return NULL;

  keyInfoCtx = xmlSecKeyInfoCtxPtr_get(keyInfoCtx_obj);
  output = PythonFile_get(output_obj);
  xmlSecKeyInfoCtxDebugDump(keyInfoCtx, output);

  Py_INCREF(Py_None);
  return (Py_None);
}
예제 #2
0
/**
 * xmlSecEncCtxDebugDump:
 * @encCtx:             the pointer to <enc:EncryptedData/> processing context.
 * @output:             the pointer to output FILE.
 *
 * Prints the debug information about @encCtx to @output.
 */
void
xmlSecEncCtxDebugDump(xmlSecEncCtxPtr encCtx, FILE* output) {
    xmlSecAssert(encCtx != NULL);
    xmlSecAssert(output != NULL);

    switch(encCtx->mode) {
    case xmlEncCtxModeEncryptedData:
        if(encCtx->operation == xmlSecTransformOperationEncrypt) {
            fprintf(output, "= DATA ENCRYPTION CONTEXT\n");
        } else {
            fprintf(output, "= DATA DECRYPTION CONTEXT\n");
        }
        break;
    case xmlEncCtxModeEncryptedKey:
        if(encCtx->operation == xmlSecTransformOperationEncrypt) {
            fprintf(output, "= KEY ENCRYPTION CONTEXT\n");
        } else {
            fprintf(output, "= KEY DECRYPTION CONTEXT\n");
        }
        break;
    }
    fprintf(output, "== Status: %s\n",
            (encCtx->resultReplaced) ? "replaced" : "not-replaced" );

    fprintf(output, "== flags: 0x%08x\n", encCtx->flags);
    fprintf(output, "== flags2: 0x%08x\n", encCtx->flags2);

    if(encCtx->id != NULL) {
        fprintf(output, "== Id: \"%s\"\n", encCtx->id);
    }
    if(encCtx->type != NULL) {
        fprintf(output, "== Type: \"%s\"\n", encCtx->type);
    }
    if(encCtx->mimeType != NULL) {
        fprintf(output, "== MimeType: \"%s\"\n", encCtx->mimeType);
    }
    if(encCtx->encoding != NULL) {
        fprintf(output, "== Encoding: \"%s\"\n", encCtx->encoding);
    }
    if(encCtx->recipient != NULL) {
        fprintf(output, "== Recipient: \"%s\"\n", encCtx->recipient);
    }
    if(encCtx->carriedKeyName != NULL) {
        fprintf(output, "== CarriedKeyName: \"%s\"\n", encCtx->carriedKeyName);
    }

    fprintf(output, "== Key Info Read Ctx:\n");
    xmlSecKeyInfoCtxDebugDump(&(encCtx->keyInfoReadCtx), output);

    fprintf(output, "== Key Info Write Ctx:\n");
    xmlSecKeyInfoCtxDebugDump(&(encCtx->keyInfoWriteCtx), output);

    fprintf(output, "== Encryption Transform Ctx:\n");
    xmlSecTransformCtxDebugDump(&(encCtx->transformCtx), output);

    if(encCtx->encMethod != NULL) {
        fprintf(output, "== Encryption Method:\n");
        xmlSecTransformDebugDump(encCtx->encMethod, output);
    }

    if(encCtx->encKey != NULL) {
        fprintf(output, "== Encryption Key:\n");
        xmlSecKeyDebugDump(encCtx->encKey, output);
    }

    if((encCtx->result != NULL) &&
            (xmlSecBufferGetData(encCtx->result) != NULL) &&
            (encCtx->resultBase64Encoded != 0)) {

        fprintf(output, "== Result - start buffer:\n");
        fwrite(xmlSecBufferGetData(encCtx->result),
               xmlSecBufferGetSize(encCtx->result), 1,
               output);
        fprintf(output, "\n== Result - end buffer\n");
    }
}