diff options
author | Tadeusz Struk <tadeusz.struk@intel.com> | 2015-06-15 16:18:36 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-06-16 02:35:06 -0400 |
commit | d37e296979ed1652aec6850e2d736bd0ebf0cdb1 (patch) | |
tree | 6f26c2f3a80bbf2e04c3be67edb22631d705de95 /lib/mpi/mpiutil.c | |
parent | 4beb106045976b785a05e77ab5430ad04b6038b7 (diff) |
MPILIB: add mpi_read_buf() and mpi_get_size() helpers
Added a mpi_read_buf() helper function to export MPI to a buf provided by
the user, and a mpi_get_size() helper, that tells the user how big the buf is.
Changed mpi_free to use kzfree instead of kfree because it is used to free
crypto keys.
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'lib/mpi/mpiutil.c')
-rw-r--r-- | lib/mpi/mpiutil.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/mpi/mpiutil.c b/lib/mpi/mpiutil.c index bf076d281d40..314f4dfa603e 100644 --- a/lib/mpi/mpiutil.c +++ b/lib/mpi/mpiutil.c | |||
@@ -69,7 +69,7 @@ void mpi_free_limb_space(mpi_ptr_t a) | |||
69 | if (!a) | 69 | if (!a) |
70 | return; | 70 | return; |
71 | 71 | ||
72 | kfree(a); | 72 | kzfree(a); |
73 | } | 73 | } |
74 | 74 | ||
75 | void mpi_assign_limb_space(MPI a, mpi_ptr_t ap, unsigned nlimbs) | 75 | void mpi_assign_limb_space(MPI a, mpi_ptr_t ap, unsigned nlimbs) |
@@ -95,7 +95,7 @@ int mpi_resize(MPI a, unsigned nlimbs) | |||
95 | if (!p) | 95 | if (!p) |
96 | return -ENOMEM; | 96 | return -ENOMEM; |
97 | memcpy(p, a->d, a->alloced * sizeof(mpi_limb_t)); | 97 | memcpy(p, a->d, a->alloced * sizeof(mpi_limb_t)); |
98 | kfree(a->d); | 98 | kzfree(a->d); |
99 | a->d = p; | 99 | a->d = p; |
100 | } else { | 100 | } else { |
101 | a->d = kzalloc(nlimbs * sizeof(mpi_limb_t), GFP_KERNEL); | 101 | a->d = kzalloc(nlimbs * sizeof(mpi_limb_t), GFP_KERNEL); |
@@ -112,7 +112,7 @@ void mpi_free(MPI a) | |||
112 | return; | 112 | return; |
113 | 113 | ||
114 | if (a->flags & 4) | 114 | if (a->flags & 4) |
115 | kfree(a->d); | 115 | kzfree(a->d); |
116 | else | 116 | else |
117 | mpi_free_limb_space(a->d); | 117 | mpi_free_limb_space(a->d); |
118 | 118 | ||