egalloc.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. EGpub*
  13. egpuballoc(void)
  14. {
  15. EGpub *eg;
  16. eg = mallocz(sizeof(*eg), 1);
  17. if(eg == nil)
  18. sysfatal("egpuballoc");
  19. return eg;
  20. }
  21. void
  22. egpubfree(EGpub *eg)
  23. {
  24. if(eg == nil)
  25. return;
  26. mpfree(eg->p);
  27. mpfree(eg->alpha);
  28. mpfree(eg->key);
  29. }
  30. EGpriv*
  31. egprivalloc(void)
  32. {
  33. EGpriv *eg;
  34. eg = mallocz(sizeof(*eg), 1);
  35. if(eg == nil)
  36. sysfatal("egprivalloc");
  37. return eg;
  38. }
  39. void
  40. egprivfree(EGpriv *eg)
  41. {
  42. if(eg == nil)
  43. return;
  44. mpfree(eg->pub.p);
  45. mpfree(eg->pub.alpha);
  46. mpfree(eg->pub.key);
  47. mpfree(eg->secret);
  48. }
  49. EGsig*
  50. egsigalloc(void)
  51. {
  52. EGsig *eg;
  53. eg = mallocz(sizeof(*eg), 1);
  54. if(eg == nil)
  55. sysfatal("egsigalloc");
  56. return eg;
  57. }
  58. void
  59. egsigfree(EGsig *eg)
  60. {
  61. if(eg == nil)
  62. return;
  63. mpfree(eg->r);
  64. mpfree(eg->s);
  65. }