e_null.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 1995-2021 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 <stdio.h>
  10. #include "internal/cryptlib.h"
  11. #include <openssl/evp.h>
  12. #include <openssl/objects.h>
  13. #include "crypto/evp.h"
  14. static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
  15. const unsigned char *iv, int enc);
  16. static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
  17. const unsigned char *in, size_t inl);
  18. static const EVP_CIPHER n_cipher = {
  19. NID_undef,
  20. 1, 0, 0, 0,
  21. EVP_ORIG_GLOBAL,
  22. null_init_key,
  23. null_cipher,
  24. NULL,
  25. 0,
  26. NULL,
  27. NULL,
  28. NULL,
  29. NULL
  30. };
  31. const EVP_CIPHER *EVP_enc_null(void)
  32. {
  33. return &n_cipher;
  34. }
  35. static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
  36. const unsigned char *iv, int enc)
  37. {
  38. return 1;
  39. }
  40. static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
  41. const unsigned char *in, size_t inl)
  42. {
  43. if (in != out)
  44. memcpy(out, in, inl);
  45. return 1;
  46. }