rotp 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *.gem
2
2
  .bundle
3
3
  Gemfile.lock
4
+ .yardoc
4
5
  pkg/*
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ # /.rspec
2
+ --format nested
3
+ --color
@@ -0,0 +1,41 @@
1
+ # ROTP - The Ruby One Time Password Library
2
+
3
+ ## Dependencies
4
+
5
+ * OpenSSL
6
+ * Base32
7
+
8
+ ## Installation
9
+
10
+ gem install rotp
11
+
12
+ ## Use
13
+
14
+ ### Time based OTP's
15
+
16
+ totp = ROTP::TOTP.new("base32secret1234")
17
+ totp.now # => 492039
18
+ totp.at(Time.now.to_i + 30) # => 102922
19
+
20
+ ### Counter based OTP's
21
+
22
+ hotp = ROTP::HOTP.new("base32secretkey1234")
23
+ hotp.at(0) # => 368431
24
+ hotp.at(1) # => 818794
25
+ hotp.at(1401) # => 320657
26
+
27
+
28
+ ### Generating a Base32 Secret key
29
+
30
+ ROTP.random_base32 # returns a 16 character base32 secret. Compatible with Google Authenticator
31
+
32
+ ### Google Authenticator Interop
33
+
34
+ The library works with the Google Authenticator iPhone and Android app, and also
35
+ includes the ability to generate provisioning URI's for use with the QR Code scanner
36
+ built into the app.
37
+
38
+ hotp.provisioning_uri # => 'otpauth://totp/alice@google.com?secret=JBSWY3DPEHPK3PXP'
39
+
40
+ This can then be rendered as a QR Code which can then be scanned and added to the users
41
+ list of OTP credentials.
@@ -0,0 +1,308 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta name="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>Class: ROTP::HOTP</title>
7
+ <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
8
+ <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+
10
+ <script type="text/javascript" charset="utf-8">
11
+ relpath = '..';
12
+ if (relpath != '') relpath += '/';
13
+ </script>
14
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
15
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
16
+
17
+ </head>
18
+ <body>
19
+ <script type="text/javascript" charset="utf-8">
20
+ if (window.top.frames.main) document.body.className = 'frames';
21
+ </script>
22
+
23
+ <div id="header">
24
+ <div id="menu">
25
+
26
+ <a href="../_index.html">Index (H)</a> &raquo;
27
+ <span class='title'><span class='object_link'><a href="../ROTP.html" title="ROTP (module)">ROTP</a></span></span>
28
+ &raquo;
29
+ <span class="title">HOTP</span>
30
+
31
+
32
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
33
+ </div>
34
+
35
+ <div id="search">
36
+ <a id="class_list_link" href="#">Class List</a>
37
+ <a id="method_list_link" href="#">Method List</a>
38
+ <a id ="file_list_link" href="#">File List</a>
39
+ </div>
40
+
41
+ <div class="clear"></div>
42
+ </div>
43
+
44
+ <iframe id="search_frame"></iframe>
45
+
46
+ <div id="content"><h1>Class: ROTP::HOTP
47
+
48
+
49
+
50
+ </h1>
51
+
52
+ <dl class="box">
53
+
54
+ <dt class="r1">Inherits:</dt>
55
+ <dd class="r1">
56
+ <span class="inheritName"><span class='object_link'><a href="OTP.html" title="ROTP::OTP (class)">OTP</a></span></span>
57
+
58
+ <ul class="fullTree">
59
+ <li>Object</li>
60
+
61
+ <li class="next"><span class='object_link'><a href="OTP.html" title="ROTP::OTP (class)">OTP</a></span></li>
62
+
63
+ <li class="next">ROTP::HOTP</li>
64
+
65
+ </ul>
66
+ <a href="#" class="inheritanceTree">show all</a>
67
+
68
+ </dd>
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+ <dt class="r2 last">Defined in:</dt>
79
+ <dd class="r2 last">lib/rotp/hotp.rb</dd>
80
+
81
+ </dl>
82
+ <div class="clear"></div>
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+ <h2>
93
+ Instance Method Summary
94
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
95
+ </h2>
96
+
97
+ <ul class="summary">
98
+
99
+ <li class="public ">
100
+ <span class="summary_signature">
101
+
102
+ <a href="#at-instance_method" title="#at (instance method)">- (Object) <strong>at</strong>(count) </a>
103
+
104
+
105
+
106
+ </span>
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+ <span class="summary_desc"><div class='inline'></div></span>
116
+
117
+ </li>
118
+
119
+
120
+ <li class="public ">
121
+ <span class="summary_signature">
122
+
123
+ <a href="#provisioning_uri-instance_method" title="#provisioning_uri (instance method)">- (String) <strong>provisioning_uri</strong>(name, start_count = 0) </a>
124
+
125
+
126
+
127
+ </span>
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+ <span class="summary_desc"><div class='inline'><p>
137
+ Returns the provisioning URI for the OTP This can then be encoded in a QR
138
+ Code and used to provision the Google Authenticator app.
139
+ </p>
140
+ </div></span>
141
+
142
+ </li>
143
+
144
+
145
+ </ul>
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="OTP.html" title="ROTP::OTP (class)">OTP</a></span></h3>
157
+ <p class="inherited"><span class='object_link'><a href="OTP.html#byte_secret-instance_method" title="ROTP::OTP#byte_secret (method)">#byte_secret</a></span>, <span class='object_link'><a href="OTP.html#generate_otp-instance_method" title="ROTP::OTP#generate_otp (method)">#generate_otp</a></span>, <span class='object_link'><a href="OTP.html#initialize-instance_method" title="ROTP::OTP#initialize (method)">#initialize</a></span>, <span class='object_link'><a href="OTP.html#int_to_bytestring-instance_method" title="ROTP::OTP#int_to_bytestring (method)">#int_to_bytestring</a></span></p>
158
+ <div id="constructor_details" class="method_details_list">
159
+ <h2>Constructor Details</h2>
160
+
161
+ <p class="notice">This class inherits a constructor from <span class='object_link'><a href="OTP.html#initialize-instance_method" title="ROTP::OTP#initialize (method)">ROTP::OTP</a></span></p>
162
+
163
+ </div>
164
+
165
+
166
+ <div id="instance_method_details" class="method_details_list">
167
+ <h2>Instance Method Details</h2>
168
+
169
+
170
+ <div class="method_details first">
171
+ <p class="signature first" id="at-instance_method">
172
+
173
+ - (<tt>Object</tt>) <strong>at</strong>(count)
174
+
175
+
176
+
177
+ </p><table class="source_code">
178
+ <tr>
179
+ <td>
180
+ <pre class="lines">
181
+
182
+
183
+ 3
184
+ 4
185
+ 5</pre>
186
+ </td>
187
+ <td>
188
+ <pre class="code"><span class="info file"># File 'lib/rotp/hotp.rb', line 3</span>
189
+
190
+ <span class='def def kw'>def</span> <span class='at identifier id'>at</span><span class='lparen token'>(</span><span class='count identifier id'>count</span><span class='rparen token'>)</span>
191
+ <span class='generate_otp identifier id'>generate_otp</span><span class='lparen token'>(</span><span class='count identifier id'>count</span><span class='rparen token'>)</span>
192
+ <span class='end end kw'>end</span>
193
+ </pre>
194
+ </td>
195
+ </tr>
196
+ </table>
197
+ </div>
198
+
199
+ <div class="method_details ">
200
+ <p class="signature " id="provisioning_uri-instance_method">
201
+
202
+ - (<tt>String</tt>) <strong>provisioning_uri</strong>(name, start_count = 0)
203
+
204
+
205
+
206
+ </p><div class="docstring">
207
+ <div class="discussion">
208
+ <p>
209
+ Returns the provisioning URI for the OTP This can then be encoded in a QR
210
+ Code and used to provision the Google Authenticator app
211
+ </p>
212
+
213
+
214
+ </div>
215
+ </div>
216
+ <div class="tags">
217
+ <h3>Parameters:</h3>
218
+ <ul class="param">
219
+
220
+ <li>
221
+
222
+ <span class='type'>(<tt>String</tt>)</span>
223
+
224
+
225
+ <span class='name'>name</span>
226
+
227
+
228
+
229
+ &mdash;
230
+ <div class='inline'><p>
231
+ of the account
232
+ </p>
233
+ </div>
234
+
235
+ </li>
236
+
237
+ <li>
238
+
239
+ <span class='type'>(<tt>Integer</tt>)</span>
240
+
241
+
242
+ <span class='name'>initial</span>
243
+
244
+
245
+
246
+ &mdash;
247
+ <div class='inline'><p>
248
+ counter value, defaults to 0
249
+ </p>
250
+ </div>
251
+
252
+ </li>
253
+
254
+ </ul>
255
+ <h3>Returns:</h3>
256
+ <ul class="return">
257
+
258
+ <li>
259
+
260
+ <span class='type'>(<tt>String</tt>)</span>
261
+
262
+
263
+
264
+
265
+ &mdash;
266
+ <div class='inline'><p>
267
+ provisioning uri
268
+ </p>
269
+ </div>
270
+
271
+ </li>
272
+
273
+ </ul>
274
+
275
+ </div><table class="source_code">
276
+ <tr>
277
+ <td>
278
+ <pre class="lines">
279
+
280
+
281
+ 13
282
+ 14
283
+ 15</pre>
284
+ </td>
285
+ <td>
286
+ <pre class="code"><span class="info file"># File 'lib/rotp/hotp.rb', line 13</span>
287
+
288
+ <span class='def def kw'>def</span> <span class='provisioning_uri identifier id'>provisioning_uri</span><span class='lparen token'>(</span><span class='name identifier id'>name</span><span class='comma token'>,</span> <span class='start_count identifier id'>start_count</span><span class='assign token'>=</span><span class='integer val'>0</span><span class='rparen token'>)</span>
289
+ <span class='dstring node'>&quot;otpauth://hotp/#{URI.encode(name)}?secret=#{secret}&amp;counter=#{start_count}&quot;</span>
290
+ <span class='end end kw'>end</span>
291
+ </pre>
292
+ </td>
293
+ </tr>
294
+ </table>
295
+ </div>
296
+
297
+ </div>
298
+
299
+ </div>
300
+
301
+ <div id="footer">
302
+ Generated on Sun Feb 13 12:31:41 2011 by
303
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
304
+ 0.6.4 (ruby-1.8.7).
305
+ </div>
306
+
307
+ </body>
308
+ </html>
@@ -0,0 +1,593 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta name="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>Class: ROTP::OTP</title>
7
+ <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
8
+ <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+
10
+ <script type="text/javascript" charset="utf-8">
11
+ relpath = '..';
12
+ if (relpath != '') relpath += '/';
13
+ </script>
14
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
15
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
16
+
17
+ </head>
18
+ <body>
19
+ <script type="text/javascript" charset="utf-8">
20
+ if (window.top.frames.main) document.body.className = 'frames';
21
+ </script>
22
+
23
+ <div id="header">
24
+ <div id="menu">
25
+
26
+ <a href="../_index.html">Index (O)</a> &raquo;
27
+ <span class='title'><span class='object_link'><a href="../ROTP.html" title="ROTP (module)">ROTP</a></span></span>
28
+ &raquo;
29
+ <span class="title">OTP</span>
30
+
31
+
32
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
33
+ </div>
34
+
35
+ <div id="search">
36
+ <a id="class_list_link" href="#">Class List</a>
37
+ <a id="method_list_link" href="#">Method List</a>
38
+ <a id ="file_list_link" href="#">File List</a>
39
+ </div>
40
+
41
+ <div class="clear"></div>
42
+ </div>
43
+
44
+ <iframe id="search_frame"></iframe>
45
+
46
+ <div id="content"><h1>Class: ROTP::OTP
47
+
48
+
49
+
50
+ </h1>
51
+
52
+ <dl class="box">
53
+
54
+ <dt class="r1">Inherits:</dt>
55
+ <dd class="r1">
56
+ <span class="inheritName">Object</span>
57
+
58
+ <ul class="fullTree">
59
+ <li>Object</li>
60
+
61
+ <li class="next">ROTP::OTP</li>
62
+
63
+ </ul>
64
+ <a href="#" class="inheritanceTree">show all</a>
65
+
66
+ </dd>
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+ <dt class="r2 last">Defined in:</dt>
77
+ <dd class="r2 last">lib/rotp/otp.rb</dd>
78
+
79
+ </dl>
80
+ <div class="clear"></div>
81
+
82
+ <div id="subclasses">
83
+ <h2>Direct Known Subclasses</h2>
84
+ <p class="children"><span class='object_link'><a href="HOTP.html" title="ROTP::HOTP (class)">HOTP</a></span>, <span class='object_link'><a href="TOTP.html" title="ROTP::TOTP (class)">TOTP</a></span></p>
85
+ </div>
86
+
87
+
88
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
89
+ <ul class="summary">
90
+
91
+ <li class="public ">
92
+ <span class="summary_signature">
93
+
94
+ <a href="#digest-instance_method" title="#digest (instance method)">- (Object) <strong>digest</strong> </a>
95
+
96
+
97
+
98
+ </span>
99
+
100
+
101
+ <span class="note title readonly">readonly</span>
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+ <span class="summary_desc"><div class='inline'><p>
111
+ Returns the value of attribute digest.
112
+ </p>
113
+ </div></span>
114
+
115
+ </li>
116
+
117
+
118
+ <li class="public ">
119
+ <span class="summary_signature">
120
+
121
+ <a href="#digits-instance_method" title="#digits (instance method)">- (Object) <strong>digits</strong> </a>
122
+
123
+
124
+
125
+ </span>
126
+
127
+
128
+ <span class="note title readonly">readonly</span>
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+ <span class="summary_desc"><div class='inline'><p>
138
+ Returns the value of attribute digits.
139
+ </p>
140
+ </div></span>
141
+
142
+ </li>
143
+
144
+
145
+ <li class="public ">
146
+ <span class="summary_signature">
147
+
148
+ <a href="#secret-instance_method" title="#secret (instance method)">- (Object) <strong>secret</strong> </a>
149
+
150
+
151
+
152
+ </span>
153
+
154
+
155
+ <span class="note title readonly">readonly</span>
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+ <span class="summary_desc"><div class='inline'><p>
165
+ Returns the value of attribute secret.
166
+ </p>
167
+ </div></span>
168
+
169
+ </li>
170
+
171
+
172
+ </ul>
173
+
174
+
175
+
176
+ <h2>
177
+ Instance Method Summary
178
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
179
+ </h2>
180
+
181
+ <ul class="summary">
182
+
183
+ <li class="public ">
184
+ <span class="summary_signature">
185
+
186
+ <a href="#byte_secret-instance_method" title="#byte_secret (instance method)">- (Object) <strong>byte_secret</strong> </a>
187
+
188
+
189
+
190
+ </span>
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+ <span class="summary_desc"><div class='inline'></div></span>
200
+
201
+ </li>
202
+
203
+
204
+ <li class="public ">
205
+ <span class="summary_signature">
206
+
207
+ <a href="#generate_otp-instance_method" title="#generate_otp (instance method)">- (Object) <strong>generate_otp</strong>(count) </a>
208
+
209
+
210
+
211
+ </span>
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+ <span class="summary_desc"><div class='inline'></div></span>
221
+
222
+ </li>
223
+
224
+
225
+ <li class="public ">
226
+ <span class="summary_signature">
227
+
228
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (OTP) <strong>initialize</strong>(s, options = {}) </a>
229
+
230
+
231
+
232
+ </span>
233
+
234
+ <span class="note title constructor">constructor</span>
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+ <span class="summary_desc"><div class='inline'><p>
244
+ Params: secret in base32.
245
+ </p>
246
+ </div></span>
247
+
248
+ </li>
249
+
250
+
251
+ <li class="public ">
252
+ <span class="summary_signature">
253
+
254
+ <a href="#int_to_bytestring-instance_method" title="#int_to_bytestring (instance method)">- (Object) <strong>int_to_bytestring</strong>(int, padding = 8) </a>
255
+
256
+
257
+
258
+ </span>
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+ <span class="summary_desc"><div class='inline'></div></span>
268
+
269
+ </li>
270
+
271
+
272
+ </ul>
273
+
274
+
275
+ <div id="constructor_details" class="method_details_list">
276
+ <h2>Constructor Details</h2>
277
+
278
+ <div class="method_details first">
279
+ <p class="signature first" id="initialize-instance_method">
280
+
281
+ - (<tt><span class='object_link'><a href="" title="ROTP::OTP (class)">OTP</a></span></tt>) <strong>initialize</strong>(s, options = {})
282
+
283
+
284
+
285
+ </p><div class="docstring">
286
+ <div class="discussion">
287
+ <p>
288
+ Params: secret in base32
289
+ </p>
290
+
291
+
292
+ </div>
293
+ </div>
294
+ <div class="tags">
295
+
296
+ </div><table class="source_code">
297
+ <tr>
298
+ <td>
299
+ <pre class="lines">
300
+
301
+
302
+ 6
303
+ 7
304
+ 8
305
+ 9
306
+ 10</pre>
307
+ </td>
308
+ <td>
309
+ <pre class="code"><span class="info file"># File 'lib/rotp/otp.rb', line 6</span>
310
+
311
+ <span class='def def kw'>def</span> <span class='initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='s identifier id'>s</span><span class='comma token'>,</span> <span class='options identifier id'>options</span> <span class='assign token'>=</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span><span class='rparen token'>)</span>
312
+ <span class='@digits ivar id'>@digits</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:digits</span><span class='rbrack token'>]</span> <span class='orop op'>||</span> <span class='integer val'>6</span>
313
+ <span class='@digest ivar id'>@digest</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:digest</span><span class='rbrack token'>]</span> <span class='orop op'>||</span> <span class='string val'>&quot;sha1&quot;</span>
314
+ <span class='@secret ivar id'>@secret</span> <span class='assign token'>=</span> <span class='s identifier id'>s</span>
315
+ <span class='end end kw'>end</span>
316
+ </pre>
317
+ </td>
318
+ </tr>
319
+ </table>
320
+ </div>
321
+
322
+ </div>
323
+
324
+ <div id="instance_attr_details" class="attr_details">
325
+ <h2>Instance Attribute Details</h2>
326
+
327
+
328
+ <span id=""></span>
329
+ <span id="digest-instance_method"></span>
330
+ <div class="method_details first">
331
+ <p class="signature first" id="digest-instance_method">
332
+
333
+ - (<tt>Object</tt>) <strong>digest</strong> <span class="extras">(readonly)</span>
334
+
335
+
336
+
337
+ </p><div class="docstring">
338
+ <div class="discussion">
339
+ <p>
340
+ Returns the value of attribute digest
341
+ </p>
342
+
343
+
344
+ </div>
345
+ </div>
346
+ <div class="tags">
347
+
348
+ </div><table class="source_code">
349
+ <tr>
350
+ <td>
351
+ <pre class="lines">
352
+
353
+
354
+ 3
355
+ 4
356
+ 5</pre>
357
+ </td>
358
+ <td>
359
+ <pre class="code"><span class="info file"># File 'lib/rotp/otp.rb', line 3</span>
360
+
361
+ <span class='def def kw'>def</span> <span class='digest identifier id'>digest</span>
362
+ <span class='@digest ivar id'>@digest</span>
363
+ <span class='end end kw'>end</span>
364
+ </pre>
365
+ </td>
366
+ </tr>
367
+ </table>
368
+ </div>
369
+
370
+
371
+ <span id=""></span>
372
+ <span id="digits-instance_method"></span>
373
+ <div class="method_details ">
374
+ <p class="signature " id="digits-instance_method">
375
+
376
+ - (<tt>Object</tt>) <strong>digits</strong> <span class="extras">(readonly)</span>
377
+
378
+
379
+
380
+ </p><div class="docstring">
381
+ <div class="discussion">
382
+ <p>
383
+ Returns the value of attribute digits
384
+ </p>
385
+
386
+
387
+ </div>
388
+ </div>
389
+ <div class="tags">
390
+
391
+ </div><table class="source_code">
392
+ <tr>
393
+ <td>
394
+ <pre class="lines">
395
+
396
+
397
+ 3
398
+ 4
399
+ 5</pre>
400
+ </td>
401
+ <td>
402
+ <pre class="code"><span class="info file"># File 'lib/rotp/otp.rb', line 3</span>
403
+
404
+ <span class='def def kw'>def</span> <span class='digits identifier id'>digits</span>
405
+ <span class='@digits ivar id'>@digits</span>
406
+ <span class='end end kw'>end</span>
407
+ </pre>
408
+ </td>
409
+ </tr>
410
+ </table>
411
+ </div>
412
+
413
+
414
+ <span id=""></span>
415
+ <span id="secret-instance_method"></span>
416
+ <div class="method_details ">
417
+ <p class="signature " id="secret-instance_method">
418
+
419
+ - (<tt>Object</tt>) <strong>secret</strong> <span class="extras">(readonly)</span>
420
+
421
+
422
+
423
+ </p><div class="docstring">
424
+ <div class="discussion">
425
+ <p>
426
+ Returns the value of attribute secret
427
+ </p>
428
+
429
+
430
+ </div>
431
+ </div>
432
+ <div class="tags">
433
+
434
+ </div><table class="source_code">
435
+ <tr>
436
+ <td>
437
+ <pre class="lines">
438
+
439
+
440
+ 3
441
+ 4
442
+ 5</pre>
443
+ </td>
444
+ <td>
445
+ <pre class="code"><span class="info file"># File 'lib/rotp/otp.rb', line 3</span>
446
+
447
+ <span class='def def kw'>def</span> <span class='secret identifier id'>secret</span>
448
+ <span class='@secret ivar id'>@secret</span>
449
+ <span class='end end kw'>end</span>
450
+ </pre>
451
+ </td>
452
+ </tr>
453
+ </table>
454
+ </div>
455
+
456
+ </div>
457
+
458
+
459
+ <div id="instance_method_details" class="method_details_list">
460
+ <h2>Instance Method Details</h2>
461
+
462
+
463
+ <div class="method_details first">
464
+ <p class="signature first" id="byte_secret-instance_method">
465
+
466
+ - (<tt>Object</tt>) <strong>byte_secret</strong>
467
+
468
+
469
+
470
+ </p><table class="source_code">
471
+ <tr>
472
+ <td>
473
+ <pre class="lines">
474
+
475
+
476
+ 27
477
+ 28
478
+ 29</pre>
479
+ </td>
480
+ <td>
481
+ <pre class="code"><span class="info file"># File 'lib/rotp/otp.rb', line 27</span>
482
+
483
+ <span class='def def kw'>def</span> <span class='byte_secret identifier id'>byte_secret</span>
484
+ <span class='Base32 constant id'>Base32</span><span class='dot token'>.</span><span class='decode identifier id'>decode</span><span class='lparen token'>(</span><span class='@secret ivar id'>@secret</span><span class='rparen token'>)</span>
485
+ <span class='end end kw'>end</span>
486
+ </pre>
487
+ </td>
488
+ </tr>
489
+ </table>
490
+ </div>
491
+
492
+ <div class="method_details ">
493
+ <p class="signature " id="generate_otp-instance_method">
494
+
495
+ - (<tt>Object</tt>) <strong>generate_otp</strong>(count)
496
+
497
+
498
+
499
+ </p><table class="source_code">
500
+ <tr>
501
+ <td>
502
+ <pre class="lines">
503
+
504
+
505
+ 12
506
+ 13
507
+ 14
508
+ 15
509
+ 16
510
+ 17
511
+ 18
512
+ 19
513
+ 20
514
+ 21
515
+ 22
516
+ 23
517
+ 24
518
+ 25</pre>
519
+ </td>
520
+ <td>
521
+ <pre class="code"><span class="info file"># File 'lib/rotp/otp.rb', line 12</span>
522
+
523
+ <span class='def def kw'>def</span> <span class='generate_otp identifier id'>generate_otp</span><span class='lparen token'>(</span><span class='count identifier id'>count</span><span class='rparen token'>)</span>
524
+ <span class='hmac identifier id'>hmac</span> <span class='assign token'>=</span> <span class='OpenSSL constant id'>OpenSSL</span><span class='colon2 op'>::</span><span class='HMAC constant id'>HMAC</span><span class='dot token'>.</span><span class='digest identifier id'>digest</span><span class='lparen token'>(</span>
525
+ <span class='OpenSSL constant id'>OpenSSL</span><span class='colon2 op'>::</span><span class='Digest constant id'>Digest</span><span class='colon2 op'>::</span><span class='Digest constant id'>Digest</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='digest identifier id'>digest</span><span class='rparen token'>)</span><span class='comma token'>,</span>
526
+ <span class='byte_secret identifier id'>byte_secret</span><span class='comma token'>,</span>
527
+ <span class='int_to_bytestring identifier id'>int_to_bytestring</span><span class='lparen token'>(</span><span class='count identifier id'>count</span><span class='rparen token'>)</span>
528
+ <span class='rparen token'>)</span>
529
+
530
+ <span class='offset identifier id'>offset</span> <span class='assign token'>=</span> <span class='hmac identifier id'>hmac</span><span class='lbrack token'>[</span><span class='integer val'>19</span><span class='rbrack token'>]</span> <span class='bitand op'>&amp;</span> <span class='integer val'>0xf</span>
531
+ <span class='code identifier id'>code</span> <span class='assign token'>=</span> <span class='lparen token'>(</span><span class='hmac identifier id'>hmac</span><span class='lbrack token'>[</span><span class='offset identifier id'>offset</span><span class='rbrack token'>]</span> <span class='bitand op'>&amp;</span> <span class='integer val'>0x7f</span><span class='rparen token'>)</span> <span class='lshft op'>&lt;&lt;</span> <span class='integer val'>24</span> <span class='bitor op'>|</span>
532
+ <span class='lparen token'>(</span><span class='hmac identifier id'>hmac</span><span class='lbrack token'>[</span><span class='offset identifier id'>offset</span> <span class='plus op'>+</span> <span class='integer val'>1</span><span class='rbrack token'>]</span> <span class='bitand op'>&amp;</span> <span class='integer val'>0xff</span><span class='rparen token'>)</span> <span class='lshft op'>&lt;&lt;</span> <span class='integer val'>16</span> <span class='bitor op'>|</span>
533
+ <span class='lparen token'>(</span><span class='hmac identifier id'>hmac</span><span class='lbrack token'>[</span><span class='offset identifier id'>offset</span> <span class='plus op'>+</span> <span class='integer val'>2</span><span class='rbrack token'>]</span> <span class='bitand op'>&amp;</span> <span class='integer val'>0xff</span><span class='rparen token'>)</span> <span class='lshft op'>&lt;&lt;</span> <span class='integer val'>8</span> <span class='bitor op'>|</span>
534
+ <span class='lparen token'>(</span><span class='hmac identifier id'>hmac</span><span class='lbrack token'>[</span><span class='offset identifier id'>offset</span> <span class='plus op'>+</span> <span class='integer val'>3</span><span class='rbrack token'>]</span> <span class='bitand op'>&amp;</span> <span class='integer val'>0xff</span><span class='rparen token'>)</span>
535
+ <span class='code identifier id'>code</span> <span class='mod op'>%</span> <span class='integer val'>10</span> <span class='pow op'>**</span> <span class='digits identifier id'>digits</span>
536
+ <span class='end end kw'>end</span>
537
+ </pre>
538
+ </td>
539
+ </tr>
540
+ </table>
541
+ </div>
542
+
543
+ <div class="method_details ">
544
+ <p class="signature " id="int_to_bytestring-instance_method">
545
+
546
+ - (<tt>Object</tt>) <strong>int_to_bytestring</strong>(int, padding = 8)
547
+
548
+
549
+
550
+ </p><table class="source_code">
551
+ <tr>
552
+ <td>
553
+ <pre class="lines">
554
+
555
+
556
+ 31
557
+ 32
558
+ 33
559
+ 34
560
+ 35
561
+ 36
562
+ 37
563
+ 38</pre>
564
+ </td>
565
+ <td>
566
+ <pre class="code"><span class="info file"># File 'lib/rotp/otp.rb', line 31</span>
567
+
568
+ <span class='def def kw'>def</span> <span class='int_to_bytestring identifier id'>int_to_bytestring</span><span class='lparen token'>(</span><span class='int identifier id'>int</span><span class='comma token'>,</span> <span class='padding identifier id'>padding</span> <span class='assign token'>=</span> <span class='integer val'>8</span><span class='rparen token'>)</span>
569
+ <span class='result identifier id'>result</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
570
+ <span class='until until kw'>until</span> <span class='int identifier id'>int</span> <span class='eq op'>==</span> <span class='integer val'>0</span>
571
+ <span class='result identifier id'>result</span> <span class='lshft op'>&lt;&lt;</span> <span class='lparen token'>(</span><span class='int identifier id'>int</span> <span class='bitand op'>&amp;</span> <span class='integer val'>0x</span><span class='FF constant id'>FF</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='chr identifier id'>chr</span>
572
+ <span class='int identifier id'>int</span> <span class='opasgn op'>&gt;&gt;=</span> <span class='integer val'>8</span>
573
+ <span class='end end kw'>end</span>
574
+ <span class='result identifier id'>result</span><span class='dot token'>.</span><span class='reverse identifier id'>reverse</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='dot token'>.</span><span class='rjust identifier id'>rjust</span><span class='lparen token'>(</span><span class='integer val'>8</span><span class='comma token'>,</span> <span class='integer val'>0</span><span class='dot token'>.</span><span class='chr identifier id'>chr</span><span class='rparen token'>)</span>
575
+ <span class='end end kw'>end</span>
576
+ </pre>
577
+ </td>
578
+ </tr>
579
+ </table>
580
+ </div>
581
+
582
+ </div>
583
+
584
+ </div>
585
+
586
+ <div id="footer">
587
+ Generated on Sun Feb 13 12:31:40 2011 by
588
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
589
+ 0.6.4 (ruby-1.8.7).
590
+ </div>
591
+
592
+ </body>
593
+ </html>