2
0

keys.c 746 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 1995 Colin Plumb. All rights reserved.
  3. * For licensing and other legal details, see the file legal.c.
  4. *
  5. * keys.c - allocate and free PubKey and SecKey structures.
  6. */
  7. #include "first.h"
  8. #include "bn.h"
  9. #include "keys.h"
  10. #include "usuals.h"
  11. void
  12. pubKeyBegin(struct PubKey *pub)
  13. {
  14. if (pub) {
  15. bnBegin(&pub->n);
  16. bnBegin(&pub->e);
  17. }
  18. }
  19. void
  20. pubKeyEnd(struct PubKey *pub)
  21. {
  22. if (pub) {
  23. bnEnd(&pub->n);
  24. bnEnd(&pub->e);
  25. wipe(pub);
  26. }
  27. }
  28. void
  29. secKeyBegin(struct SecKey *sec)
  30. {
  31. if (sec) {
  32. bnBegin(&sec->d);
  33. bnBegin(&sec->p);
  34. bnBegin(&sec->q);
  35. bnBegin(&sec->u);
  36. }
  37. }
  38. void
  39. secKeyEnd(struct SecKey *sec)
  40. {
  41. if (sec) {
  42. bnEnd(&sec->d);
  43. bnEnd(&sec->p);
  44. bnEnd(&sec->q);
  45. bnEnd(&sec->u);
  46. wipe(sec);
  47. }
  48. }