dsaalloc.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "os.h"
  10. #include <mp.h>
  11. #include <libsec.h>
  12. DSApub*
  13. dsapuballoc(void)
  14. {
  15. DSApub *dsa;
  16. dsa = mallocz(sizeof(*dsa), 1);
  17. if(dsa == nil)
  18. sysfatal("dsapuballoc");
  19. return dsa;
  20. }
  21. void
  22. dsapubfree(DSApub *dsa)
  23. {
  24. if(dsa == nil)
  25. return;
  26. mpfree(dsa->p);
  27. mpfree(dsa->q);
  28. mpfree(dsa->alpha);
  29. mpfree(dsa->key);
  30. }
  31. DSApriv*
  32. dsaprivalloc(void)
  33. {
  34. DSApriv *dsa;
  35. dsa = mallocz(sizeof(*dsa), 1);
  36. if(dsa == nil)
  37. sysfatal("dsaprivalloc");
  38. return dsa;
  39. }
  40. void
  41. dsaprivfree(DSApriv *dsa)
  42. {
  43. if(dsa == nil)
  44. return;
  45. mpfree(dsa->pub.p);
  46. mpfree(dsa->pub.q);
  47. mpfree(dsa->pub.alpha);
  48. mpfree(dsa->pub.key);
  49. mpfree(dsa->secret);
  50. }
  51. DSAsig*
  52. dsasigalloc(void)
  53. {
  54. DSAsig *dsa;
  55. dsa = mallocz(sizeof(*dsa), 1);
  56. if(dsa == nil)
  57. sysfatal("dsasigalloc");
  58. return dsa;
  59. }
  60. void
  61. dsasigfree(DSAsig *dsa)
  62. {
  63. if(dsa == nil)
  64. return;
  65. mpfree(dsa->r);
  66. mpfree(dsa->s);
  67. }