algchoic.h 3.18 KB
Newer Older
1
2
3
4
5
6
7
8
/* Copyright (C) RSA Data Security, Inc. created 1993, 1996.  This is an
   unpublished work protected as such under copyright law.  This work
   contains proprietary, confidential, and trade secret information of
   RSA Data Security, Inc.  Use, disclosure or reproduction without the
   express written authorization of RSA Data Security, Inc. is
   prohibited.
 */

9
10
#ifndef DNSSAFE_ALGCHOIC_H
#define DNSSAFE_ALGCHOIC_H 1
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109

#define IS_FATAL_BSAFE_ERROR(status) \
  (status == BE_ALLOC || status == BE_HARDWARE || status == BE_CANCEL)

/* Use the THIS_ALGA_CHOICE macro to define the type of object in the
     INIT_ALGA prototype.  It defaults to the AlgaChoice, but
     derived modules may define the macro to a more derived class before
     including this header file.
 */
struct AlgaChoice;
#ifndef THIS_ALGA_CHOICE
#define THIS_ALGA_CHOICE struct AlgaChoice
#endif

/* In C++:
class ResizeContext {
public:
  ResizeContext ();
  ~ResizeContext ();
  int makeNewContext (unsigned int contextSize);
  POINTER context () {return z.context;}

private:
  struct {
    POINTER context;
    unsigned int contextSize;
  } z;
};

class AlgaChoice;
typedef int (*INIT_ALGA)
  (THIS_ALGA_CHOICE *algaChoice, POINTER keyInfo,
   struct B_ALGORITHM_METHOD *algorithmMethod,
   A_SURRENDER_CTX *surrenderContext);

class AlgaChoice {
public:
  AlgaChoice (INIT_ALGA InitAlga) : _InitAlga (InitAlga) {}
  ~AlgaChoice () {}
  int choose
    (int encryptFlag, B_Key *key, B_ALGORITHM_CHOOSER chooser,
     A_SURRENDER_CTX *surrenderContext);
  int makeNewContext (unsigned int contextSize) {
    context.makeNewContext (contextSize); }
  POINTER alga () {return _alga;}
  POINTER algorithmInfo () {return _algorithmInfo;}
  POINTER context () {return context.context ();}
  void setAlgorithmInfoType (B_AlgorithmInfoType *algorithmInfoType) {
    _algorithmInfoType = algorithmInfoType;
  }
  void setAlgorithmInfo (POINTER algorithmInfo) {
    _algorithmInfo = algorithmInfo;
  }

private:
  POINTER _alga;
  B_AlgorithmInfoType *_algorithmInfoType;
  POINTER _algorithmInfo;
  INIT_ALGA _InitAlga;

  ResizeContext context;
};
 */

typedef struct ResizeContext {
  struct {
    POINTER context;
    unsigned int contextSize;
  } z;                                            /* zeriozed by constructor */
} ResizeContext;

typedef int (*INIT_ALGA) PROTO_LIST
  ((THIS_ALGA_CHOICE *, POINTER, struct B_ALGORITHM_METHOD *,
    A_SURRENDER_CTX *));

typedef struct AlgaChoice {
  POINTER _alga;
  struct B_AlgorithmInfoType *_algorithmInfoType;
  POINTER _algorithmInfo;
  INIT_ALGA _InitAlga;

  ResizeContext context;
} AlgaChoice;

void ResizeContextConstructor PROTO_LIST ((ResizeContext *));
void ResizeContextDestructor PROTO_LIST ((ResizeContext *));
int ResizeContextMakeNewContext PROTO_LIST ((ResizeContext *, unsigned int));

#define ALGA_CHOICE_Constructor(algaChoice, InitAlga)\
  (ResizeContextConstructor (&(algaChoice)->context), \
   (algaChoice)->_InitAlga = (InitAlga))
#define ALGA_CHOICE_Destructor(algaChoice)\
  (ResizeContextDestructor (&(algaChoice)->context))

int AlgaChoiceChoose PROTO_LIST
  ((AlgaChoice *, int, B_Key *, B_ALGORITHM_CHOOSER, A_SURRENDER_CTX *));

int ConvertAlgaeError PROTO_LIST ((int));

110
#endif /* DNSSAFE_ALGCHOIC_H */