n_pkey.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include "openssl/opensslconf.h"
  10. #ifdef OPENSSL_NO_RSA
  11. NON_EMPTY_TRANSLATION_UNIT
  12. #else
  13. # include "internal/cryptlib.h"
  14. # include <stdio.h>
  15. # include <openssl/rsa.h>
  16. # include <openssl/objects.h>
  17. # include <openssl/asn1t.h>
  18. # include <openssl/evp.h>
  19. # include <openssl/x509.h>
  20. # ifndef OPENSSL_NO_RC4
  21. # define ASN1_BROKEN_SEQUENCE(tname) \
  22. static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \
  23. ASN1_SEQUENCE(tname)
  24. # define static_ASN1_BROKEN_SEQUENCE_END(stname) \
  25. static_ASN1_SEQUENCE_END_ref(stname, stname)
  26. typedef struct netscape_pkey_st {
  27. int32_t version;
  28. X509_ALGOR *algor;
  29. ASN1_OCTET_STRING *private_key;
  30. } NETSCAPE_PKEY;
  31. typedef struct netscape_encrypted_pkey_st {
  32. ASN1_OCTET_STRING *os;
  33. /*
  34. * This is the same structure as DigestInfo so use it: although this
  35. * isn't really anything to do with digests.
  36. */
  37. X509_SIG *enckey;
  38. } NETSCAPE_ENCRYPTED_PKEY;
  39. ASN1_BROKEN_SEQUENCE(NETSCAPE_ENCRYPTED_PKEY) = {
  40. ASN1_SIMPLE(NETSCAPE_ENCRYPTED_PKEY, os, ASN1_OCTET_STRING),
  41. ASN1_SIMPLE(NETSCAPE_ENCRYPTED_PKEY, enckey, X509_SIG)
  42. } static_ASN1_BROKEN_SEQUENCE_END(NETSCAPE_ENCRYPTED_PKEY)
  43. DECLARE_ASN1_FUNCTIONS(NETSCAPE_ENCRYPTED_PKEY)
  44. DECLARE_ASN1_ENCODE_FUNCTIONS_name(NETSCAPE_ENCRYPTED_PKEY, NETSCAPE_ENCRYPTED_PKEY)
  45. IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_ENCRYPTED_PKEY)
  46. ASN1_SEQUENCE(NETSCAPE_PKEY) = {
  47. ASN1_EMBED(NETSCAPE_PKEY, version, INT32),
  48. ASN1_SIMPLE(NETSCAPE_PKEY, algor, X509_ALGOR),
  49. ASN1_SIMPLE(NETSCAPE_PKEY, private_key, ASN1_OCTET_STRING)
  50. } static_ASN1_SEQUENCE_END(NETSCAPE_PKEY)
  51. DECLARE_ASN1_FUNCTIONS(NETSCAPE_PKEY)
  52. DECLARE_ASN1_ENCODE_FUNCTIONS_name(NETSCAPE_PKEY, NETSCAPE_PKEY)
  53. IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_PKEY)
  54. # endif /* OPENSSL_NO_RC4 */
  55. #endif