e_null.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (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. null_init_key,
  22. null_cipher,
  23. NULL,
  24. 0,
  25. NULL,
  26. NULL,
  27. NULL,
  28. NULL
  29. };
  30. const EVP_CIPHER *EVP_enc_null(void)
  31. {
  32. return &n_cipher;
  33. }
  34. static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
  35. const unsigned char *iv, int enc)
  36. {
  37. return 1;
  38. }
  39. static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
  40. const unsigned char *in, size_t inl)
  41. {
  42. if (in != out)
  43. memcpy(out, in, inl);
  44. return 1;
  45. }