krypt-provider-openssl 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/ext/krypt/provider/openssl/extconf.rb +79 -0
- data/ext/krypt/provider/openssl/krypt-provider-ossl.h +60 -0
- data/ext/krypt/provider/openssl/krypt-provider.h +86 -0
- data/ext/krypt/provider/openssl/krypt_ossl_digest.c +202 -0
- data/ext/krypt/provider/openssl/krypt_provider_ossl.c +47 -0
- data/lib/krypt-provider-openssl.rb +34 -0
- data/lib/kryptprovideropenssl.so +0 -0
- metadata +54 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011-2013 Hiroshi Nakamura, Martin Boßlet
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,79 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
= Info
|
4
|
+
|
5
|
+
krypt-provider-openssl - Implementation using OpenSSL
|
6
|
+
|
7
|
+
Copyright (C) 2011-2013
|
8
|
+
Hiroshi Nakamura <nahi@ruby-lang.org>
|
9
|
+
Martin Bosslet <martin.bosslet@gmail.com>
|
10
|
+
All rights reserved.
|
11
|
+
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
13
|
+
a copy of this software and associated documentation files (the
|
14
|
+
"Software"), to deal in the Software without restriction, including
|
15
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
16
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
17
|
+
permit persons to whom the Software is furnished to do so, subject to
|
18
|
+
the following conditions:
|
19
|
+
|
20
|
+
The above copyright notice and this permission notice shall be
|
21
|
+
included in all copies or substantial portions of the Software.
|
22
|
+
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
24
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
25
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
26
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
27
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
28
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
29
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
30
|
+
|
31
|
+
=end
|
32
|
+
|
33
|
+
require 'mkmf'
|
34
|
+
|
35
|
+
dir_config("openssl")
|
36
|
+
|
37
|
+
message "=== krypt-provider OpenSSL ===\n"
|
38
|
+
|
39
|
+
arg = ARGV.shift
|
40
|
+
if arg
|
41
|
+
if arg.include? "-g"
|
42
|
+
debug = true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
##
|
47
|
+
# Automatically adds -Wall flag for compilation when GCC is used
|
48
|
+
#
|
49
|
+
if CONFIG['GCC'] == 'yes'
|
50
|
+
$CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall"
|
51
|
+
end
|
52
|
+
|
53
|
+
message "=== Checking for system dependencies... ===\n"
|
54
|
+
have_library("nsl", "t_open")
|
55
|
+
have_library("socket", "socket")
|
56
|
+
have_header("assert.h")
|
57
|
+
|
58
|
+
message "=== Checking requirements... ===\n"
|
59
|
+
if $mingw
|
60
|
+
have_library("wsock32")
|
61
|
+
have_library("gdi32")
|
62
|
+
end
|
63
|
+
|
64
|
+
result = pkg_config("openssl") && have_header("openssl/ssl.h")
|
65
|
+
|
66
|
+
unless result
|
67
|
+
result = have_header("openssl/ssl.h")
|
68
|
+
result &&= %w[crypto libeay32].any? {|lib| have_library(lib, "OpenSSL_add_all_digests")}
|
69
|
+
result &&= %w[ssl ssleay32].any? {|lib| have_library(lib, "SSL_library_init")}
|
70
|
+
unless result
|
71
|
+
message "=== Checking for requirements failed. ===\n"
|
72
|
+
message "Makefile wasn't created. Please fix the errors above.\n"
|
73
|
+
exit 1
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
create_header
|
78
|
+
create_makefile("kryptprovideropenssl")
|
79
|
+
message "Done.\n"
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/*
|
2
|
+
* krypt-provider-openssl - Implementation using OpenSSL
|
3
|
+
*
|
4
|
+
* Copyright (c) 2011-2013
|
5
|
+
* Hiroshi Nakamura <nahi@ruby-lang.org>
|
6
|
+
* Martin Bosslet <martin.bosslet@gmail.com>
|
7
|
+
* All rights reserved.
|
8
|
+
*
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
10
|
+
* a copy of this software and associated documentation files (the
|
11
|
+
* "Software"), to deal in the Software without restriction, including
|
12
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
13
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
14
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
15
|
+
* the following conditions:
|
16
|
+
*
|
17
|
+
* The above copyright notice and this permission notice shall be
|
18
|
+
* included in all copies or substantial portions of the Software.
|
19
|
+
*
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
21
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
23
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
24
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
25
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
26
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
|
+
*/
|
28
|
+
|
29
|
+
#ifndef _KRYPT_PROVIDER_OSSL_H_
|
30
|
+
#define _KRYPT_PROVIDER_OSSL_H_
|
31
|
+
|
32
|
+
#if defined(__cplusplus)
|
33
|
+
extern "C" {
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#include <openssl/opensslv.h>
|
37
|
+
|
38
|
+
#if defined(_WIN32)
|
39
|
+
# include <openssl/e_os2.h>
|
40
|
+
# define OSSL_NO_CONF_API 1
|
41
|
+
# ifndef OPENSSL_SYS_WIN32
|
42
|
+
# define OPENSSL_SYS_WIN32 1
|
43
|
+
# endif
|
44
|
+
# include <winsock2.h>
|
45
|
+
#endif
|
46
|
+
|
47
|
+
#include <errno.h>
|
48
|
+
#include <openssl/err.h>
|
49
|
+
#include <openssl/ssl.h>
|
50
|
+
|
51
|
+
extern krypt_provider krypt_provider_ossl;
|
52
|
+
|
53
|
+
krypt_md * krypt_ossl_md_new_oid(krypt_provider *provider, const char *oid);
|
54
|
+
krypt_md * krypt_ossl_md_new_name(krypt_provider *provider, const char *name);
|
55
|
+
|
56
|
+
#if defined(__cplusplus)
|
57
|
+
}
|
58
|
+
#endif
|
59
|
+
|
60
|
+
#endif /* _KRYPT_PROVIDER_H_ */
|
@@ -0,0 +1,86 @@
|
|
1
|
+
/*
|
2
|
+
* krypt-provider-openssl - Implementation using OpenSSL
|
3
|
+
*
|
4
|
+
* Copyright (c) 2011-2013
|
5
|
+
* Hiroshi Nakamura <nahi@ruby-lang.org>
|
6
|
+
* Martin Bosslet <martin.bosslet@gmail.com>
|
7
|
+
* All rights reserved.
|
8
|
+
*
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
10
|
+
* a copy of this software and associated documentation files (the
|
11
|
+
* "Software"), to deal in the Software without restriction, including
|
12
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
13
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
14
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
15
|
+
* the following conditions:
|
16
|
+
*
|
17
|
+
* The above copyright notice and this permission notice shall be
|
18
|
+
* included in all copies or substantial portions of the Software.
|
19
|
+
*
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
21
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
23
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
24
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
25
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
26
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
|
+
*/
|
28
|
+
|
29
|
+
#ifndef _KRYPT_PROVIDER_H_
|
30
|
+
#define _KRYPT_PROVIDER_H_
|
31
|
+
|
32
|
+
|
33
|
+
#ifndef _RSTRING_NOT_MODIFIED
|
34
|
+
#define RSTRING_NOT_MODIFIED 1
|
35
|
+
#endif
|
36
|
+
|
37
|
+
#ifndef RUBY_READONLY_STRING
|
38
|
+
#define RUBY_READONLY_STRING 1
|
39
|
+
#endif
|
40
|
+
|
41
|
+
#include <ruby.h>
|
42
|
+
|
43
|
+
#ifndef KRYPT_OK
|
44
|
+
#define KRYPT_OK 1
|
45
|
+
#endif
|
46
|
+
#ifndef KRYPT_ERR
|
47
|
+
#define KRYPT_ERR -1
|
48
|
+
#endif
|
49
|
+
|
50
|
+
typedef struct krypt_provider_st krypt_provider;
|
51
|
+
|
52
|
+
/* Message digest */
|
53
|
+
typedef struct krypt_interface_md_st krypt_interface_md;
|
54
|
+
|
55
|
+
typedef struct krypt_md_st {
|
56
|
+
krypt_provider *provider;
|
57
|
+
krypt_interface_md *methods;
|
58
|
+
} krypt_md;
|
59
|
+
|
60
|
+
struct krypt_interface_md_st {
|
61
|
+
int (*md_reset)(krypt_md *md);
|
62
|
+
int (*md_update)(krypt_md *md, const void *data, size_t len);
|
63
|
+
int (*md_final)(krypt_md *md, uint8_t ** digest, size_t *len);
|
64
|
+
int (*md_digest)(krypt_md *md, const uint8_t *data, size_t len, uint8_t **digest, size_t *digest_len);
|
65
|
+
int (*md_digest_length)(krypt_md *md, size_t *len);
|
66
|
+
int (*md_block_length)(krypt_md *md, size_t *block_len);
|
67
|
+
int (*md_name)(krypt_md *md, const char **name);
|
68
|
+
void (*mark)(krypt_md *md);
|
69
|
+
void (*free)(krypt_md *md);
|
70
|
+
};
|
71
|
+
|
72
|
+
/* Provider */
|
73
|
+
struct krypt_provider_st {
|
74
|
+
const char *name;
|
75
|
+
krypt_md *(*md_new_oid)(krypt_provider *provider, const char *oid);
|
76
|
+
krypt_md *(*md_new_name)(krypt_provider *provider, const char *name);
|
77
|
+
};
|
78
|
+
|
79
|
+
/* Can be called from within a provider implementation to indicate errors */
|
80
|
+
extern void krypt_error_add(const char * format, ...);
|
81
|
+
|
82
|
+
/* May be used to register a singleton provider upon initialization */
|
83
|
+
extern void krypt_provider_register(krypt_provider *provider);
|
84
|
+
|
85
|
+
#endif /* _KRYPT_PROVIDER_H_ */
|
86
|
+
|
@@ -0,0 +1,202 @@
|
|
1
|
+
/*
|
2
|
+
* krypt-provider-openssl - Implementation using OpenSSL
|
3
|
+
*
|
4
|
+
* Copyright (c) 2011-2013
|
5
|
+
* Hiroshi Nakamura <nahi@ruby-lang.org>
|
6
|
+
* Martin Bosslet <martin.bosslet@gmail.com>
|
7
|
+
* All rights reserved.
|
8
|
+
*
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
10
|
+
* a copy of this software and associated documentation files (the
|
11
|
+
* "Software"), to deal in the Software without restriction, including
|
12
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
13
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
14
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
15
|
+
* the following conditions:
|
16
|
+
*
|
17
|
+
* The above copyright notice and this permission notice shall be
|
18
|
+
* included in all copies or substantial portions of the Software.
|
19
|
+
*
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
21
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
23
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
24
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
25
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
26
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
|
+
*/
|
28
|
+
|
29
|
+
#include "krypt-provider.h"
|
30
|
+
#include "krypt-provider-ossl.h"
|
31
|
+
|
32
|
+
typedef struct krypt_md_ossl_st {
|
33
|
+
krypt_provider *provider;
|
34
|
+
krypt_interface_md *methods;
|
35
|
+
EVP_MD_CTX *ctx;
|
36
|
+
} krypt_md_ossl;
|
37
|
+
|
38
|
+
#define int_safe_cast(dest, md) \
|
39
|
+
do { \
|
40
|
+
if ((md)->provider != &krypt_provider_ossl) return KRYPT_ERR; \
|
41
|
+
(dest) = (krypt_md_ossl *) (md); \
|
42
|
+
} while (0)
|
43
|
+
|
44
|
+
int int_md_reset(krypt_md *md);
|
45
|
+
int int_md_update(krypt_md *md, const void *data, size_t len);
|
46
|
+
int int_md_final(krypt_md *md, uint8_t ** digest, size_t *len);
|
47
|
+
int int_md_digest(krypt_md *md, const uint8_t *data, size_t len, uint8_t **digest, size_t *digest_len);
|
48
|
+
int int_md_digest_length(krypt_md *md, size_t *len);
|
49
|
+
int int_md_block_length(krypt_md *md, size_t *len);
|
50
|
+
int int_md_name(krypt_md *md, const char **name);
|
51
|
+
void int_md_mark(krypt_md *md);
|
52
|
+
void int_md_free(krypt_md *md);
|
53
|
+
|
54
|
+
krypt_interface_md krypt_interface_md_ossl = {
|
55
|
+
int_md_reset,
|
56
|
+
int_md_update,
|
57
|
+
int_md_final,
|
58
|
+
int_md_digest,
|
59
|
+
int_md_digest_length,
|
60
|
+
int_md_block_length,
|
61
|
+
int_md_name,
|
62
|
+
NULL,
|
63
|
+
int_md_free
|
64
|
+
};
|
65
|
+
|
66
|
+
static krypt_md_ossl *
|
67
|
+
int_md_alloc(void)
|
68
|
+
{
|
69
|
+
krypt_md_ossl *md = (krypt_md_ossl *) malloc(sizeof(krypt_md_ossl));
|
70
|
+
memset(md, 0, sizeof(krypt_md_ossl));
|
71
|
+
md->provider = &krypt_provider_ossl;
|
72
|
+
md->methods = &krypt_interface_md_ossl;
|
73
|
+
return md;
|
74
|
+
}
|
75
|
+
|
76
|
+
#define return_krypt_ossl_md() \
|
77
|
+
do { \
|
78
|
+
if (!md) return NULL; \
|
79
|
+
if (!(ctx = EVP_MD_CTX_create())) return NULL; \
|
80
|
+
if (!(ret = int_md_alloc())) return NULL; \
|
81
|
+
if (EVP_DigestInit_ex(ctx, md, NULL) != 1) return NULL; \
|
82
|
+
ret->ctx = ctx; \
|
83
|
+
return (krypt_md *)ret; \
|
84
|
+
} while (0)
|
85
|
+
|
86
|
+
krypt_md *
|
87
|
+
krypt_ossl_md_new_oid(krypt_provider *provider, const char *oid)
|
88
|
+
{
|
89
|
+
EVP_MD_CTX *ctx;
|
90
|
+
const EVP_MD *md;
|
91
|
+
krypt_md_ossl *ret;
|
92
|
+
ASN1_OBJECT *ossl_oid;
|
93
|
+
|
94
|
+
if (provider != &krypt_provider_ossl) return NULL;
|
95
|
+
|
96
|
+
ossl_oid = OBJ_txt2obj(oid, 0);
|
97
|
+
md = EVP_get_digestbyobj(ossl_oid);
|
98
|
+
ASN1_OBJECT_free(ossl_oid);
|
99
|
+
return_krypt_ossl_md();
|
100
|
+
}
|
101
|
+
|
102
|
+
krypt_md *
|
103
|
+
krypt_ossl_md_new_name(krypt_provider *provider, const char *name)
|
104
|
+
{
|
105
|
+
EVP_MD_CTX *ctx;
|
106
|
+
const EVP_MD *md;
|
107
|
+
krypt_md_ossl *ret;
|
108
|
+
|
109
|
+
if (provider != &krypt_provider_ossl) return NULL;
|
110
|
+
|
111
|
+
md = EVP_get_digestbyname(name);
|
112
|
+
return_krypt_ossl_md();
|
113
|
+
}
|
114
|
+
|
115
|
+
int
|
116
|
+
int_md_reset(krypt_md *ext)
|
117
|
+
{
|
118
|
+
krypt_md_ossl *md;
|
119
|
+
|
120
|
+
int_safe_cast(md, ext);
|
121
|
+
if (EVP_DigestInit_ex(md->ctx, EVP_MD_CTX_md(md->ctx), NULL) != 1)
|
122
|
+
return KRYPT_ERR;
|
123
|
+
return KRYPT_OK;
|
124
|
+
}
|
125
|
+
|
126
|
+
int
|
127
|
+
int_md_update(krypt_md *ext, const void *data, size_t len)
|
128
|
+
{
|
129
|
+
krypt_md_ossl *md;
|
130
|
+
|
131
|
+
int_safe_cast(md, ext);
|
132
|
+
EVP_DigestUpdate(md->ctx, data, len);
|
133
|
+
return KRYPT_OK;
|
134
|
+
}
|
135
|
+
|
136
|
+
int
|
137
|
+
int_md_final(krypt_md *ext, uint8_t ** digest, size_t *len)
|
138
|
+
{
|
139
|
+
krypt_md_ossl *md;
|
140
|
+
uint8_t *ret;
|
141
|
+
size_t ret_len;
|
142
|
+
|
143
|
+
int_safe_cast(md, ext);
|
144
|
+
ret_len = EVP_MD_CTX_size(md->ctx);
|
145
|
+
ret = (uint8_t *) malloc(ret_len);
|
146
|
+
EVP_DigestFinal_ex(md->ctx, (unsigned char *)ret, NULL);
|
147
|
+
|
148
|
+
*digest = ret;
|
149
|
+
*len = ret_len;
|
150
|
+
return KRYPT_OK;
|
151
|
+
}
|
152
|
+
|
153
|
+
int
|
154
|
+
int_md_digest(krypt_md *ext, const uint8_t *data, size_t len, uint8_t **digest, size_t *digest_len)
|
155
|
+
{
|
156
|
+
if (!int_md_update(ext, data, len)) return KRYPT_ERR;
|
157
|
+
return int_md_final(ext, digest, digest_len);
|
158
|
+
}
|
159
|
+
|
160
|
+
int
|
161
|
+
int_md_digest_length(krypt_md *ext, size_t *len)
|
162
|
+
{
|
163
|
+
krypt_md_ossl *md;
|
164
|
+
|
165
|
+
int_safe_cast(md, ext);
|
166
|
+
*len = EVP_MD_CTX_size(md->ctx);
|
167
|
+
return KRYPT_OK;
|
168
|
+
}
|
169
|
+
|
170
|
+
int
|
171
|
+
int_md_block_length(krypt_md *ext, size_t *len)
|
172
|
+
{
|
173
|
+
krypt_md_ossl *md;
|
174
|
+
|
175
|
+
int_safe_cast(md, ext);
|
176
|
+
*len = EVP_MD_CTX_block_size(md->ctx);
|
177
|
+
return KRYPT_OK;
|
178
|
+
}
|
179
|
+
|
180
|
+
int
|
181
|
+
int_md_name(krypt_md *ext, const char **name)
|
182
|
+
{
|
183
|
+
krypt_md_ossl *md;
|
184
|
+
|
185
|
+
int_safe_cast(md, ext);
|
186
|
+
*name = EVP_MD_name(EVP_MD_CTX_md(md->ctx));
|
187
|
+
return KRYPT_OK;
|
188
|
+
}
|
189
|
+
|
190
|
+
void
|
191
|
+
int_md_free(krypt_md *ext)
|
192
|
+
{
|
193
|
+
krypt_md_ossl *md;
|
194
|
+
|
195
|
+
if (!ext) return;
|
196
|
+
if ((ext)->provider != &krypt_provider_ossl) return;
|
197
|
+
md = (krypt_md_ossl *) ext;
|
198
|
+
if (md->ctx)
|
199
|
+
EVP_MD_CTX_destroy(md->ctx);
|
200
|
+
free(md);
|
201
|
+
}
|
202
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
/*
|
2
|
+
* krypt-provider-openssl - Implementation using OpenSSL
|
3
|
+
*
|
4
|
+
* Copyright (c) 2011-2013
|
5
|
+
* Hiroshi Nakamura <nahi@ruby-lang.org>
|
6
|
+
* Martin Bosslet <martin.bosslet@gmail.com>
|
7
|
+
* All rights reserved.
|
8
|
+
*
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
10
|
+
* a copy of this software and associated documentation files (the
|
11
|
+
* "Software"), to deal in the Software without restriction, including
|
12
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
13
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
14
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
15
|
+
* the following conditions:
|
16
|
+
*
|
17
|
+
* The above copyright notice and this permission notice shall be
|
18
|
+
* included in all copies or substantial portions of the Software.
|
19
|
+
*
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
21
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
23
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
24
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
25
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
26
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
|
+
*/
|
28
|
+
|
29
|
+
#include "krypt-provider.h"
|
30
|
+
#include "krypt-provider-ossl.h"
|
31
|
+
|
32
|
+
krypt_provider krypt_provider_ossl = {
|
33
|
+
"openssl",
|
34
|
+
krypt_ossl_md_new_oid,
|
35
|
+
krypt_ossl_md_new_name
|
36
|
+
};
|
37
|
+
|
38
|
+
void
|
39
|
+
Init_kryptprovideropenssl(void)
|
40
|
+
{
|
41
|
+
OpenSSL_add_ssl_algorithms();
|
42
|
+
OpenSSL_add_all_algorithms();
|
43
|
+
ERR_load_crypto_strings();
|
44
|
+
SSL_load_error_strings();
|
45
|
+
|
46
|
+
krypt_provider_register(&krypt_provider_ossl);
|
47
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
= Info
|
4
|
+
|
5
|
+
krypt-provider-openssl - Implementation using OpenSSL
|
6
|
+
|
7
|
+
Copyright (C) 2011-2013
|
8
|
+
Hiroshi Nakamura <nahi@ruby-lang.org>
|
9
|
+
Martin Bosslet <martin.bosslet@gmail.com>
|
10
|
+
All rights reserved.
|
11
|
+
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
13
|
+
a copy of this software and associated documentation files (the
|
14
|
+
"Software"), to deal in the Software without restriction, including
|
15
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
16
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
17
|
+
permit persons to whom the Software is furnished to do so, subject to
|
18
|
+
the following conditions:
|
19
|
+
|
20
|
+
The above copyright notice and this permission notice shall be
|
21
|
+
included in all copies or substantial portions of the Software.
|
22
|
+
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
24
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
25
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
26
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
27
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
28
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
29
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
30
|
+
|
31
|
+
=end
|
32
|
+
|
33
|
+
require 'kryptprovideropenssl.so'
|
34
|
+
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: krypt-provider-openssl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Hiroshi Nakamura, Martin Bosslet
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Implementation of the krypt-provider API using OpenSSL
|
15
|
+
email: Martin.Bosslet@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions:
|
18
|
+
- ext/krypt/provider/openssl/extconf.rb
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- LICENSE
|
22
|
+
- ext/krypt/provider/openssl/krypt_ossl_digest.c
|
23
|
+
- ext/krypt/provider/openssl/extconf.rb
|
24
|
+
- ext/krypt/provider/openssl/krypt_provider_ossl.c
|
25
|
+
- ext/krypt/provider/openssl/krypt-provider-ossl.h
|
26
|
+
- ext/krypt/provider/openssl/krypt-provider.h
|
27
|
+
- lib/kryptprovideropenssl.so
|
28
|
+
- lib/krypt-provider-openssl.rb
|
29
|
+
homepage: https://github.com/krypt/krypt-provider-openssl
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.9.3
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.8.23
|
51
|
+
signing_key:
|
52
|
+
specification_version: 3
|
53
|
+
summary: Default provider for C(++)-based Rubies
|
54
|
+
test_files: []
|