mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 22:21:21 +00:00
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>
This commit is contained in:
parent
4beb106045
commit
d37e296979
3 changed files with 86 additions and 22 deletions
|
@ -81,6 +81,8 @@ MPI mpi_read_from_buffer(const void *buffer, unsigned *ret_nread);
|
|||
int mpi_fromstr(MPI val, const char *str);
|
||||
u32 mpi_get_keyid(MPI a, u32 *keyid);
|
||||
void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign);
|
||||
int mpi_read_buffer(MPI a, uint8_t *buf, unsigned buf_len, unsigned *nbytes,
|
||||
int *sign);
|
||||
void *mpi_get_secure_buffer(MPI a, unsigned *nbytes, int *sign);
|
||||
int mpi_set_buffer(MPI a, const void *buffer, unsigned nbytes, int sign);
|
||||
|
||||
|
@ -142,4 +144,17 @@ int mpi_rshift(MPI x, MPI a, unsigned n);
|
|||
/*-- mpi-inv.c --*/
|
||||
int mpi_invm(MPI x, MPI u, MPI v);
|
||||
|
||||
/* inline functions */
|
||||
|
||||
/**
|
||||
* mpi_get_size() - returns max size required to store the number
|
||||
*
|
||||
* @a: A multi precision integer for which we want to allocate a bufer
|
||||
*
|
||||
* Return: size required to store the number
|
||||
*/
|
||||
static inline unsigned int mpi_get_size(MPI a)
|
||||
{
|
||||
return a->nlimbs * BYTES_PER_MPI_LIMB;
|
||||
}
|
||||
#endif /*G10_MPI_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue