encutil.c 964 B

12345678910111213141516171819202122232425262728293031323334
  1. /* -*- Mode: C; tab-width: 8 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "secasn1.h"
  6. #include "crmf.h"
  7. #include "crmfi.h"
  8. void
  9. crmf_encoder_out(void *arg, const char *buf, unsigned long len,
  10. int depth, SEC_ASN1EncodingPart data_kind)
  11. {
  12. struct crmfEncoderOutput *output;
  13. output = (struct crmfEncoderOutput *)arg;
  14. output->fn(output->outputArg, buf, len);
  15. }
  16. SECStatus
  17. cmmf_user_encode(void *src, CRMFEncoderOutputCallback inCallback, void *inArg,
  18. const SEC_ASN1Template *inTemplate)
  19. {
  20. struct crmfEncoderOutput output;
  21. PORT_Assert(src != NULL);
  22. if (src == NULL) {
  23. return SECFailure;
  24. }
  25. output.fn = inCallback;
  26. output.outputArg = inArg;
  27. return SEC_ASN1Encode(src, inTemplate, crmf_encoder_out, &output);
  28. }