Coverage Report

Created: 2025-07-11 06:48

/src/strongswan/src/libstrongswan/plugins/pkcs1/pkcs1_plugin.c
Line
Count
Source
1
/*
2
 * Copyright (C) 2009 Martin Willi
3
 *
4
 * Copyright (C) secunet Security Networks AG
5
 *
6
 * This program is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License as published by the
8
 * Free Software Foundation; either version 2 of the License, or (at your
9
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
10
 *
11
 * This program is distributed in the hope that it will be useful, but
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
 * for more details.
15
 */
16
17
#include "pkcs1_plugin.h"
18
19
#include <library.h>
20
#include "pkcs1_builder.h"
21
#include "pkcs1_encoder.h"
22
23
typedef struct private_pkcs1_plugin_t private_pkcs1_plugin_t;
24
25
/**
26
 * private data of pkcs1_plugin
27
 */
28
struct private_pkcs1_plugin_t {
29
30
  /**
31
   * public functions
32
   */
33
  pkcs1_plugin_t public;
34
};
35
36
METHOD(plugin_t, get_name, char*,
37
  private_pkcs1_plugin_t *this)
38
87.2k
{
39
87.2k
  return "pkcs1";
40
87.2k
}
41
42
METHOD(plugin_t, get_features, int,
43
  private_pkcs1_plugin_t *this, plugin_feature_t *features[])
44
14.5k
{
45
14.5k
  static plugin_feature_t f[] = {
46
14.5k
    PLUGIN_REGISTER(PRIVKEY, pkcs1_private_key_load, FALSE),
47
14.5k
      PLUGIN_PROVIDE(PRIVKEY, KEY_ANY),
48
14.5k
        PLUGIN_SDEPEND(PRIVKEY, KEY_RSA),
49
14.5k
        PLUGIN_SDEPEND(PRIVKEY, KEY_ECDSA),
50
14.5k
    PLUGIN_REGISTER(PRIVKEY, pkcs1_private_key_load, FALSE),
51
14.5k
      PLUGIN_PROVIDE(PRIVKEY, KEY_RSA),
52
14.5k
    PLUGIN_REGISTER(PUBKEY, pkcs1_public_key_load, FALSE),
53
14.5k
      PLUGIN_PROVIDE(PUBKEY, KEY_ANY),
54
14.5k
        PLUGIN_SDEPEND(PUBKEY, KEY_RSA),
55
14.5k
        PLUGIN_SDEPEND(PUBKEY, KEY_ECDSA),
56
14.5k
        PLUGIN_SDEPEND(PUBKEY, KEY_ED25519),
57
14.5k
        PLUGIN_SDEPEND(PUBKEY, KEY_ED448),
58
14.5k
        PLUGIN_SDEPEND(PUBKEY, KEY_DSA),
59
14.5k
    PLUGIN_REGISTER(PUBKEY, pkcs1_public_key_load, FALSE),
60
14.5k
      PLUGIN_PROVIDE(PUBKEY, KEY_RSA),
61
14.5k
  };
62
14.5k
  *features = f;
63
14.5k
  return countof(f);
64
14.5k
}
65
66
METHOD(plugin_t, destroy, void,
67
  private_pkcs1_plugin_t *this)
68
14.5k
{
69
14.5k
  lib->encoding->remove_encoder(lib->encoding, pkcs1_encoder_encode);
70
71
14.5k
  free(this);
72
14.5k
}
73
74
/*
75
 * see header file
76
 */
77
plugin_t *pkcs1_plugin_create()
78
14.5k
{
79
14.5k
  private_pkcs1_plugin_t *this;
80
81
14.5k
  INIT(this,
82
14.5k
    .public = {
83
14.5k
      .plugin = {
84
14.5k
        .get_name = _get_name,
85
14.5k
        .get_features = _get_features,
86
14.5k
        .destroy = _destroy,
87
14.5k
      },
88
14.5k
    },
89
14.5k
  );
90
91
14.5k
  lib->encoding->add_encoder(lib->encoding, pkcs1_encoder_encode);
92
93
14.5k
  return &this->public.plugin;
94
14.5k
}
95