summaryrefslogtreecommitdiff
path: root/lib/dns/sec/dnssafe/ahgen.c
blob: 342166839a038877fc805c1d0955c6d9bf3b9727 (plain)
1
2
3
4
5
6
7
8
9
10
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
/* Copyright (C) RSA Data Security, Inc. created 1990, 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.
 */

#include "global.h"
#include "bsafe2.h"
#include "bkey.h"
#include "balg.h"
#include "ahgen.h"

static void TypedAHGenerateDestructor PROTO_LIST ((B_TypeCheck *));

void AHGenerateConstructor (handler)
AHGenerate *handler;
{
  /* Construct base class, setting type tag. */
  B_TYPE_CHECK_Constructor
    (&handler->typeCheck, TypedAHGenerateDestructor);

  /* Don't set vTable since this is a pure virtual base class. */
}

int B_AlgorithmGenerateInit (algorithm, algorithmChooser, surrenderContext)
B_Algorithm *algorithm;
B_ALGORITHM_CHOOSER algorithmChooser;
A_SURRENDER_CTX *surrenderContext;
{
  int status;

  if ((status = B_AlgorithmCheckType
       (algorithm, TypedAHGenerateDestructor)) != 0)
    return (status);

  if ((status =
       (*((AHGenerate *)algorithm->z.handler)->vTable->GenerateInit)
       ((AHGenerate *)algorithm->z.handler, algorithmChooser,
        surrenderContext)) != 0)
    return (status);

  algorithm->z.initFlag = 1;
  return (0);
}

int B_AlgorithmGenerateKeypair
  (algorithm, publicKey, privateKey, randomAlgorithm, surrenderContext)
B_Algorithm *algorithm;
B_Key *publicKey;
B_Key *privateKey;
B_Algorithm *randomAlgorithm;
A_SURRENDER_CTX *surrenderContext;
{
  int status;

  if ((status = B_AlgorithmCheckTypeAndInitFlag
       (algorithm, TypedAHGenerateDestructor)) != 0)
    return (status);

  return ((*((AHGenerate *)algorithm->z.handler)->vTable->GenerateKeypair)
          ((AHGenerate *)algorithm->z.handler, publicKey, privateKey,
           randomAlgorithm, surrenderContext));
}

int B_AlgorithmGenerateParameters
  (algorithm, resultAlgorithm, randomAlgorithm, surrenderContext)
B_Algorithm *algorithm;
B_Algorithm *resultAlgorithm;
B_Algorithm *randomAlgorithm;
A_SURRENDER_CTX *surrenderContext;
{
  int status;

  if ((status = B_AlgorithmCheckTypeAndInitFlag
       (algorithm, TypedAHGenerateDestructor)) != 0)
    return (status);

  return ((*((AHGenerate *)algorithm->z.handler)->vTable->GenerateParameters)
          ((AHGenerate *)algorithm->z.handler, resultAlgorithm,
           randomAlgorithm, surrenderContext));
}

static void TypedAHGenerateDestructor (typeCheck)
B_TypeCheck *typeCheck;
{
  (*((AHGenerate *)typeCheck)->vTable->Destructor) ((AHGenerate *)typeCheck);
}