iragsdale-rubydkim 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -46,10 +46,11 @@ end
46
46
  if defined?(Gem) and defined?(Rake::GemPackageTask)
47
47
 
48
48
  spec_ext = Gem::Specification.new do |s|
49
- s.name = 'rubydkim'
49
+ s.name = 'iragsdale-rubydkim'
50
50
  s.version = PKG_VERSION
51
51
  s.summary = "A gem for creating & verifying DKIM signatures"
52
52
  s.description = "This is a DKIM implementation as a Ruby extension in C."
53
+ s.add_dependency('dnsruby')
53
54
 
54
55
  s.files = PKG_FILES
55
56
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2
1
+ 0.3
data/bin/dkim_sign.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require "dkim"
4
4
 
5
5
  domain, selector, keyfile = ARGV
6
- key = File.readlines(keyfile).to_s
6
+ key = File.readlines(keyfile).join
7
7
 
8
8
  # read the email
9
9
  signer = DKIM::Signer.new(domain, selector, key)
data/rubydkim.gemspec CHANGED
@@ -1,12 +1,12 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  Gem::Specification.new do |s|
4
- s.name = %q{rubydkim}
5
- s.version = "0.2"
4
+ s.name = %q{iragsdale-rubydkim}
5
+ s.version = "0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ian Ragsdale"]
9
- s.date = %q{2009-09-04}
9
+ s.date = %q{2009-09-11}
10
10
  s.default_executable = %q{dkim_verify.rb}
11
11
  s.description = %q{This is a DKIM implementation as a Ruby extension in C.}
12
12
  s.email = %q{ian.ragsdale@gmail.com}
@@ -23,8 +23,11 @@ Gem::Specification.new do |s|
23
23
  s.specification_version = 2
24
24
 
25
25
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_runtime_dependency(%q<dnsruby>, [">= 0"])
26
27
  else
28
+ s.add_dependency(%q<dnsruby>, [">= 0"])
27
29
  end
28
30
  else
31
+ s.add_dependency(%q<dnsruby>, [">= 0"])
29
32
  end
30
33
  end
@@ -1,15 +1,18 @@
1
1
  #include "ruby.h"
2
- #include "rubyio.h"
3
2
  #include "pdkim1.h"
3
+ #ifndef GetWriteFile
4
+ #include "ruby/io.h"
5
+ #define GetWriteFile(fp) rb_io_stdio_file(fp)
6
+ #define OpenFile rb_io_t
7
+ #else
8
+ #include "rubyio.h"
9
+ #endif
4
10
 
5
11
  static VALUE mDKIM, cDKIMSigner, cDKIMSignature, cTime;
6
12
 
7
13
  // feed data to the dkim context
8
14
  VALUE signer_feed(VALUE obj, VALUE text)
9
- {
10
- // create a pointer for the length of the string
11
- int length;
12
-
15
+ {
13
16
  // get the dkim context
14
17
  pdkim_ctx *ctx;
15
18
  Data_Get_Struct(obj, pdkim_ctx, ctx);
@@ -18,10 +21,10 @@ VALUE signer_feed(VALUE obj, VALUE text)
18
21
  char * data = StringValuePtr(text);
19
22
 
20
23
  // pass the string data to pdkim_feed while setting the length
21
- int i = 0;
22
24
  if ( pdkim_feed(ctx, data, strlen(data)) != PDKIM_OK) {
23
25
  printf("pdkim_feed() error\n");
24
26
  }
27
+ return Qnil;
25
28
  }
26
29
 
27
30
  // create a signature object from a pdkim_signature
@@ -35,22 +38,22 @@ VALUE new_signature(pdkim_signature *sig)
35
38
  rb_iv_set(rsig, "@canon_body", INT2FIX(sig->canon_body));
36
39
  rb_iv_set(rsig, "@querymethod", INT2FIX(sig->querymethod));
37
40
  if (sig->selector != NULL)
38
- rb_iv_set(rsig, "@selector", rb_str_new2(sig->selector));
41
+ rb_iv_set(rsig, "@selector", rb_str_dup(sig->selector));
39
42
  if (sig->domain != NULL)
40
- rb_iv_set(rsig, "@domain", rb_str_new2(sig->domain));
43
+ rb_iv_set(rsig, "@domain", rb_str_dup(sig->domain));
41
44
  if (sig->identity != NULL)
42
- rb_iv_set(rsig, "@identity", rb_str_new2(sig->identity));
45
+ rb_iv_set(rsig, "@identity", rb_str_dup(sig->identity));
43
46
  if (sig->created > 0)
44
47
  rb_iv_set(rsig, "@created", rb_funcall(cTime, rb_intern("at"), 1, INT2FIX(sig->created)));
45
48
  if (sig->expires > 0)
46
49
  rb_iv_set(rsig, "@expires", rb_funcall(cTime, rb_intern("at"), 1, INT2FIX(sig->expires)));
47
50
  rb_iv_set(rsig, "@bodylength", INT2FIX(sig->bodylength));
48
51
  if (sig->headernames != NULL)
49
- rb_iv_set(rsig, "@headernames", rb_str_new2(sig->headernames));
52
+ rb_iv_set(rsig, "@headernames", rb_str_dup(sig->headernames));
50
53
  if (sig->copiedheaders != NULL)
51
- rb_iv_set(rsig, "@copiedheaders", rb_str_new2(sig->copiedheaders));
54
+ rb_iv_set(rsig, "@copiedheaders", rb_str_dup(sig->copiedheaders));
52
55
  if (sig->signature_header != NULL)
53
- rb_iv_set(rsig, "@signature_header", rb_str_new2(sig->signature_header));
56
+ rb_iv_set(rsig, "@signature_header", rb_str_dup(sig->signature_header));
54
57
  rb_iv_set(rsig, "@verify_status", INT2FIX(sig->verify_status));
55
58
  rb_iv_set(rsig, "@verify_ext_status", INT2FIX(sig->verify_ext_status));
56
59
  // rb_iv_set(rsig, "@pubkey", );
@@ -66,17 +69,18 @@ VALUE signer_finish(VALUE obj)
66
69
 
67
70
  // create a signature object
68
71
  pdkim_signature *signature;
69
- if ( pdkim_feed_finish(ctx,&signature) == PDKIM_OK ) {
72
+ int result = pdkim_feed_finish(ctx,&signature);
73
+ if ( result == PDKIM_OK ) {
70
74
  return new_signature(signature);
71
75
  }
72
76
  else {
73
- printf("pdkim_feed_finish error");
74
- return rb_str_new2("");
77
+ rb_raise(rb_eRuntimeError, "error finishing signature: %d", result);
75
78
  }
76
79
  }
77
80
 
78
81
  // frees the class when we're done
79
82
  static void signer_free(void *ctx) {
83
+ printf("freeing ctx\n");
80
84
  pdkim_free_ctx(ctx);
81
85
  }
82
86
 
@@ -124,6 +128,7 @@ VALUE signer_debug(VALUE obj, VALUE file)
124
128
  else {
125
129
  rb_raise(rb_eTypeError, "debug requires a file handle");
126
130
  }
131
+ return RUBY_T_NONE;
127
132
  }
128
133
 
129
134
  // defines the new ruby class and hooks up the proper methods
@@ -1,15 +1,18 @@
1
1
  #include "ruby.h"
2
- #include "rubyio.h"
3
2
  #include "pdkim1.h"
3
+ #ifndef GetWriteFile
4
+ #include "ruby/io.h"
5
+ #define GetWriteFile(fp) rb_io_stdio_file(fp)
6
+ #define OpenFile rb_io_t
7
+ #else
8
+ #include "rubyio.h"
9
+ #endif
4
10
 
5
11
  static VALUE mDKIM, cDKIMVerifier, cDKIMResolver, cDKIMSignature, cTime;
6
12
 
7
13
  // feed data to the dkim context
8
14
  VALUE verifier_feed(VALUE obj, VALUE text)
9
15
  {
10
- // create a pointer for the length of the string
11
- int length;
12
-
13
16
  // get the dkim context
14
17
  pdkim_ctx *ctx;
15
18
  Data_Get_Struct(obj, pdkim_ctx, ctx);
@@ -18,10 +21,10 @@ VALUE verifier_feed(VALUE obj, VALUE text)
18
21
  char * data = StringValuePtr(text);
19
22
 
20
23
  // pass the string data to pdkim_feed while setting the length
21
- int i = 0;
22
24
  if ( pdkim_feed(ctx, data, strlen(data)) != PDKIM_OK) {
23
25
  printf("pdkim_feed() error\n");
24
26
  }
27
+ return Qnil;
25
28
  }
26
29
 
27
30
  // create a signature object from a pdkim_signature
@@ -67,7 +70,9 @@ VALUE verifier_finish(VALUE obj)
67
70
 
68
71
  // finish up the call
69
72
  pdkim_signature *signatures;
70
- if ( pdkim_feed_finish(ctx,&signatures) == PDKIM_OK ) {
73
+
74
+ int result = pdkim_feed_finish(ctx,&signatures);
75
+ if ( result == PDKIM_OK ) {
71
76
 
72
77
  // create an array to hold the new signatures
73
78
  VALUE rsigs = rb_ary_new();
@@ -84,8 +89,7 @@ VALUE verifier_finish(VALUE obj)
84
89
  return rsigs;
85
90
  }
86
91
  else {
87
- printf("pdkim_feed_finish error");
88
- return rb_str_new2("");
92
+ rb_raise(rb_eRuntimeError, "error finishing signature: %d", result);
89
93
  }
90
94
  }
91
95
 
@@ -147,6 +151,7 @@ VALUE verifier_debug(VALUE obj, VALUE file)
147
151
  else {
148
152
  rb_raise(rb_eTypeError, "debug requires a file handle");
149
153
  }
154
+ return Qnil;
150
155
  }
151
156
 
152
157
  // defines the new ruby class and hooks up the proper methods
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iragsdale-rubydkim
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.2"
4
+ hash: 13
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ version: "0.3"
5
10
  platform: ruby
6
11
  authors:
7
12
  - Ian Ragsdale
@@ -9,10 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-09-04 00:00:00 -07:00
17
+ date: 2009-09-11 00:00:00 -05:00
13
18
  default_executable: dkim_verify.rb
14
- dependencies: []
15
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: dnsruby
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
16
34
  description: This is a DKIM implementation as a Ruby extension in C.
17
35
  email: ian.ragsdale@gmail.com
18
36
  executables:
@@ -24,10 +42,8 @@ extensions:
24
42
  extra_rdoc_files: []
25
43
 
26
44
  files:
27
- - bin
28
45
  - bin/dkim_sign.rb
29
46
  - bin/dkim_verify.rb
30
- - lib
31
47
  - lib/dkim.rb
32
48
  - LICENSE
33
49
  - Rakefile
@@ -35,17 +51,15 @@ files:
35
51
  - rubydkim.gemspec
36
52
  - sample_key
37
53
  - sample_key.pub
38
- - src
39
- - src/dkim
40
- - src/dkim/signer
41
54
  - src/dkim/signer/extconf.rb
42
55
  - src/dkim/signer/signer.c
43
- - src/dkim/verifier
44
56
  - src/dkim/verifier/extconf.rb
45
57
  - src/dkim/verifier/verifier.c
46
58
  - VERSION
47
- has_rdoc: false
59
+ has_rdoc: true
48
60
  homepage: http://github.com/iragsdale/rubydkim
61
+ licenses: []
62
+
49
63
  post_install_message:
50
64
  rdoc_options: []
51
65
 
@@ -53,21 +67,27 @@ require_paths:
53
67
  - lib
54
68
  - lib
55
69
  required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
56
71
  requirements:
57
72
  - - ">="
58
73
  - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
59
77
  version: "0"
60
- version:
61
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
62
80
  requirements:
63
81
  - - ">="
64
82
  - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
65
86
  version: "0"
66
- version:
67
87
  requirements: []
68
88
 
69
89
  rubyforge_project:
70
- rubygems_version: 1.2.0
90
+ rubygems_version: 1.3.7
71
91
  signing_key:
72
92
  specification_version: 2
73
93
  summary: A gem for creating & verifying DKIM signatures