src/share/native/sun/security/ec/impl/ecc_impl.h

Print this page




  26  * The Original Code is the Netscape security libraries.
  27  *
  28  * The Initial Developer of the Original Code is
  29  * Netscape Communications Corporation.
  30  * Portions created by the Initial Developer are Copyright (C) 1994-2000
  31  * the Initial Developer. All Rights Reserved.
  32  *
  33  * Contributor(s):
  34  *   Dr Vipul Gupta <vipul.gupta@sun.com> and
  35  *   Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
  36  *
  37  *********************************************************************** */
  38 
  39 #ifndef _ECC_IMPL_H
  40 #define _ECC_IMPL_H
  41 
  42 #ifdef __cplusplus
  43 extern "C" {
  44 #endif
  45 

  46 #include <sys/types.h>
  47 #include "ecl-exp.h"
  48 
  49 /*
  50  * Multi-platform definitions
  51  */
  52 #ifdef __linux__
  53 #define B_FALSE FALSE
  54 #define B_TRUE TRUE
  55 typedef unsigned char uint8_t;
  56 typedef unsigned long ulong_t;
  57 typedef enum { B_FALSE, B_TRUE } boolean_t;
  58 #endif /* __linux__ */
  59 
  60 #ifdef _ALLBSD_SOURCE
  61 #include <stdint.h>
  62 #define B_FALSE FALSE
  63 #define B_TRUE TRUE
  64 typedef unsigned long ulong_t;
  65 typedef enum boolean { B_FALSE, B_TRUE } boolean_t;


  84 #endif  /* _KERNEL */
  85 
  86 #define EC_MAX_DIGEST_LEN 1024  /* max digest that can be signed */
  87 #define EC_MAX_POINT_LEN 145    /* max len of DER encoded Q */
  88 #define EC_MAX_VALUE_LEN 72     /* max len of ANSI X9.62 private value d */
  89 #define EC_MAX_SIG_LEN 144      /* max signature len for supported curves */
  90 #define EC_MIN_KEY_LEN  112     /* min key length in bits */
  91 #define EC_MAX_KEY_LEN  571     /* max key length in bits */
  92 #define EC_MAX_OID_LEN 10       /* max length of OID buffer */
  93 
  94 /*
  95  * Various structures and definitions from NSS are here.
  96  */
  97 
  98 #ifdef _KERNEL
  99 #define PORT_ArenaAlloc(a, n, f)        kmem_alloc((n), (f))
 100 #define PORT_ArenaZAlloc(a, n, f)       kmem_zalloc((n), (f))
 101 #define PORT_ArenaGrow(a, b, c, d)      NULL
 102 #define PORT_ZAlloc(n, f)               kmem_zalloc((n), (f))
 103 #define PORT_Alloc(n, f)                kmem_alloc((n), (f))





 104 #else
 105 #define PORT_ArenaAlloc(a, n, f)        malloc((n))
 106 #define PORT_ArenaZAlloc(a, n, f)       calloc(1, (n))
 107 #define PORT_ArenaGrow(a, b, c, d)      NULL
 108 #define PORT_ZAlloc(n, f)               calloc(1, (n))
 109 #define PORT_Alloc(n, f)                malloc((n))





 110 #endif
 111 
 112 #define PORT_NewArena(b)                (char *)12345
 113 #define PORT_ArenaMark(a)               NULL
 114 #define PORT_ArenaUnmark(a, b)
 115 #define PORT_ArenaRelease(a, m)
 116 #define PORT_FreeArena(a, b)
 117 #define PORT_Strlen(s)                  strlen((s))
 118 #define PORT_SetError(e)
 119 
 120 #define PRBool                          boolean_t
 121 #define PR_TRUE                         B_TRUE
 122 #define PR_FALSE                        B_FALSE
 123 
 124 #ifdef _KERNEL
 125 #define PORT_Assert                     ASSERT
 126 #define PORT_Memcpy(t, f, l)            bcopy((f), (t), (l))
 127 #else
 128 #define PORT_Assert                     assert
 129 #define PORT_Memcpy(t, f, l)            memcpy((t), (f), (l))




  26  * The Original Code is the Netscape security libraries.
  27  *
  28  * The Initial Developer of the Original Code is
  29  * Netscape Communications Corporation.
  30  * Portions created by the Initial Developer are Copyright (C) 1994-2000
  31  * the Initial Developer. All Rights Reserved.
  32  *
  33  * Contributor(s):
  34  *   Dr Vipul Gupta <vipul.gupta@sun.com> and
  35  *   Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
  36  *
  37  *********************************************************************** */
  38 
  39 #ifndef _ECC_IMPL_H
  40 #define _ECC_IMPL_H
  41 
  42 #ifdef __cplusplus
  43 extern "C" {
  44 #endif
  45 
  46 #include <string.h>
  47 #include <sys/types.h>
  48 #include "ecl-exp.h"
  49 
  50 /*
  51  * Multi-platform definitions
  52  */
  53 #ifdef __linux__
  54 #define B_FALSE FALSE
  55 #define B_TRUE TRUE
  56 typedef unsigned char uint8_t;
  57 typedef unsigned long ulong_t;
  58 typedef enum { B_FALSE, B_TRUE } boolean_t;
  59 #endif /* __linux__ */
  60 
  61 #ifdef _ALLBSD_SOURCE
  62 #include <stdint.h>
  63 #define B_FALSE FALSE
  64 #define B_TRUE TRUE
  65 typedef unsigned long ulong_t;
  66 typedef enum boolean { B_FALSE, B_TRUE } boolean_t;


  85 #endif  /* _KERNEL */
  86 
  87 #define EC_MAX_DIGEST_LEN 1024  /* max digest that can be signed */
  88 #define EC_MAX_POINT_LEN 145    /* max len of DER encoded Q */
  89 #define EC_MAX_VALUE_LEN 72     /* max len of ANSI X9.62 private value d */
  90 #define EC_MAX_SIG_LEN 144      /* max signature len for supported curves */
  91 #define EC_MIN_KEY_LEN  112     /* min key length in bits */
  92 #define EC_MAX_KEY_LEN  571     /* max key length in bits */
  93 #define EC_MAX_OID_LEN 10       /* max length of OID buffer */
  94 
  95 /*
  96  * Various structures and definitions from NSS are here.
  97  */
  98 
  99 #ifdef _KERNEL
 100 #define PORT_ArenaAlloc(a, n, f)        kmem_alloc((n), (f))
 101 #define PORT_ArenaZAlloc(a, n, f)       kmem_zalloc((n), (f))
 102 #define PORT_ArenaGrow(a, b, c, d)      NULL
 103 #define PORT_ZAlloc(n, f)               kmem_zalloc((n), (f))
 104 #define PORT_Alloc(n, f)                kmem_alloc((n), (f))
 105 #define PORT_ZFree(p, l) \
 106   do {                   \
 107     memset((p), 0, (l)); \
 108     kmem_free((p), (l)); \
 109   } while (0)
 110 #else
 111 #define PORT_ArenaAlloc(a, n, f)        malloc((n))
 112 #define PORT_ArenaZAlloc(a, n, f)       calloc(1, (n))
 113 #define PORT_ArenaGrow(a, b, c, d)      NULL
 114 #define PORT_ZAlloc(n, f)               calloc(1, (n))
 115 #define PORT_Alloc(n, f)                malloc((n))
 116 #define PORT_ZFree(p, l) \
 117   do {                   \
 118     memset((p), 0, (l)); \
 119     free((p));           \
 120   } while (0)
 121 #endif
 122 
 123 #define PORT_NewArena(b)                (char *)12345
 124 #define PORT_ArenaMark(a)               NULL
 125 #define PORT_ArenaUnmark(a, b)
 126 #define PORT_ArenaRelease(a, m)
 127 #define PORT_FreeArena(a, b)
 128 #define PORT_Strlen(s)                  strlen((s))
 129 #define PORT_SetError(e)
 130 
 131 #define PRBool                          boolean_t
 132 #define PR_TRUE                         B_TRUE
 133 #define PR_FALSE                        B_FALSE
 134 
 135 #ifdef _KERNEL
 136 #define PORT_Assert                     ASSERT
 137 #define PORT_Memcpy(t, f, l)            bcopy((f), (t), (l))
 138 #else
 139 #define PORT_Assert                     assert
 140 #define PORT_Memcpy(t, f, l)            memcpy((t), (f), (l))