diff options
author | tb <> | 2024-01-02 21:12:25 +0000 |
---|---|---|
committer | tb <> | 2024-01-02 21:12:25 +0000 |
commit | 216b98e81b538b1efad6f22921c31880951ae373 (patch) | |
tree | e0d4ebdada31b4e1c251c10fc7d46b54954df143 /src | |
parent | aef2d8eade403830e2678e242586504b864edea7 (diff) | |
download | openbsd-216b98e81b538b1efad6f22921c31880951ae373.tar.gz openbsd-216b98e81b538b1efad6f22921c31880951ae373.tar.bz2 openbsd-216b98e81b538b1efad6f22921c31880951ae373.zip |
Move down EVP_CIPHER_CTX accessors expose EVP_CIPHER internals
These confusingly named getters were added "for convenience" in 1.1.
They fit best next to the EVP_CIPHER API.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/evp/evp_cipher.c | 80 |
1 files changed, 42 insertions, 38 deletions
diff --git a/src/lib/libcrypto/evp/evp_cipher.c b/src/lib/libcrypto/evp/evp_cipher.c index 367cfb6e67..d8e802e94b 100644 --- a/src/lib/libcrypto/evp/evp_cipher.c +++ b/src/lib/libcrypto/evp/evp_cipher.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: evp_cipher.c,v 1.10 2024/01/02 20:48:40 tb Exp $ */ | 1 | /* $OpenBSD: evp_cipher.c,v 1.11 2024/01/02 21:12:25 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -740,12 +740,6 @@ EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in) | |||
740 | return 1; | 740 | return 1; |
741 | } | 741 | } |
742 | 742 | ||
743 | int | ||
744 | EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx) | ||
745 | { | ||
746 | return ctx->cipher->block_size; | ||
747 | } | ||
748 | |||
749 | const EVP_CIPHER * | 743 | const EVP_CIPHER * |
750 | EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx) | 744 | EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx) |
751 | { | 745 | { |
@@ -758,12 +752,6 @@ EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx) | |||
758 | return ctx->encrypt; | 752 | return ctx->encrypt; |
759 | } | 753 | } |
760 | 754 | ||
761 | unsigned long | ||
762 | EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx) | ||
763 | { | ||
764 | return ctx->cipher->flags; | ||
765 | } | ||
766 | |||
767 | void * | 755 | void * |
768 | EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx) | 756 | EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx) |
769 | { | 757 | { |
@@ -793,25 +781,6 @@ EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data) | |||
793 | return old_cipher_data; | 781 | return old_cipher_data; |
794 | } | 782 | } |
795 | 783 | ||
796 | int | ||
797 | EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx) | ||
798 | { | ||
799 | int iv_length = 0; | ||
800 | |||
801 | if ((ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_IV_LENGTH) == 0) | ||
802 | return ctx->cipher->iv_len; | ||
803 | |||
804 | /* | ||
805 | * XXX - sanity would suggest to pass the size of the pointer along, | ||
806 | * but unfortunately we have to match the other crowd. | ||
807 | */ | ||
808 | if (EVP_CIPHER_CTX_ctrl((EVP_CIPHER_CTX *)ctx, EVP_CTRL_GET_IVLEN, 0, | ||
809 | &iv_length) != 1) | ||
810 | return -1; | ||
811 | |||
812 | return iv_length; | ||
813 | } | ||
814 | |||
815 | unsigned char * | 784 | unsigned char * |
816 | EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx) | 785 | EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx) |
817 | { | 786 | { |
@@ -825,12 +794,6 @@ EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx) | |||
825 | } | 794 | } |
826 | 795 | ||
827 | int | 796 | int |
828 | EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx) | ||
829 | { | ||
830 | return ctx->cipher->nid; | ||
831 | } | ||
832 | |||
833 | int | ||
834 | EVP_CIPHER_CTX_get_iv(const EVP_CIPHER_CTX *ctx, unsigned char *iv, size_t len) | 797 | EVP_CIPHER_CTX_get_iv(const EVP_CIPHER_CTX *ctx, unsigned char *iv, size_t len) |
835 | { | 798 | { |
836 | if (ctx == NULL || len != EVP_CIPHER_CTX_iv_length(ctx)) | 799 | if (ctx == NULL || len != EVP_CIPHER_CTX_iv_length(ctx)) |
@@ -887,6 +850,47 @@ EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags) | |||
887 | } | 850 | } |
888 | 851 | ||
889 | /* | 852 | /* |
853 | * EVP_CIPHER_CTX getters that reach into the cipher attachted to the contex. | ||
854 | */ | ||
855 | |||
856 | int | ||
857 | EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx) | ||
858 | { | ||
859 | return ctx->cipher->nid; | ||
860 | } | ||
861 | |||
862 | int | ||
863 | EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx) | ||
864 | { | ||
865 | return ctx->cipher->block_size; | ||
866 | } | ||
867 | |||
868 | int | ||
869 | EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx) | ||
870 | { | ||
871 | int iv_length = 0; | ||
872 | |||
873 | if ((ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_IV_LENGTH) == 0) | ||
874 | return ctx->cipher->iv_len; | ||
875 | |||
876 | /* | ||
877 | * XXX - sanity would suggest to pass the size of the pointer along, | ||
878 | * but unfortunately we have to match the other crowd. | ||
879 | */ | ||
880 | if (EVP_CIPHER_CTX_ctrl((EVP_CIPHER_CTX *)ctx, EVP_CTRL_GET_IVLEN, 0, | ||
881 | &iv_length) != 1) | ||
882 | return -1; | ||
883 | |||
884 | return iv_length; | ||
885 | } | ||
886 | |||
887 | unsigned long | ||
888 | EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx) | ||
889 | { | ||
890 | return ctx->cipher->flags; | ||
891 | } | ||
892 | |||
893 | /* | ||
890 | * Used by CMS and its predecessors. Only GOST and RC2 have a custom method. | 894 | * Used by CMS and its predecessors. Only GOST and RC2 have a custom method. |
891 | */ | 895 | */ |
892 | 896 | ||