Debian Codegraph @

rfc6287.html

raw
1 <pre>Internet Engineering Task Force (IETF) D. M'Raihi
2 Request for Comments: 6287 Verisign, Inc.
3 Category: Informational J. Rydell
4 ISSN: 2070-1721 Portwise, Inc.
5 S. Bajaj
6 Symantec Corp.
7 S. Machani
8 Diversinet Corp.
9 D. Naccache
10 Ecole Normale Superieure
11 June 2011
12
13
14 <span class="h1">OCRA: OATH Challenge-Response Algorithm</span>
15
16 Abstract
17
18 This document describes an algorithm for challenge-response
19 authentication developed by the Initiative for Open Authentication
20 (OATH). The specified mechanisms leverage the HMAC-based One-Time
21 Password (HOTP) algorithm and offer one-way and mutual
22 authentication, and electronic signature capabilities.
23
24 Status of This Memo
25
26 This document is not an Internet Standards Track specification; it is
27 published for informational purposes.
28
29 This document is a product of the Internet Engineering Task Force
30 (IETF). It represents the consensus of the IETF community. It has
31 received public review and has been approved for publication by the
32 Internet Engineering Steering Group (IESG). Not all documents
33 approved by the IESG are a candidate for any level of Internet
34 Standard; see <a href="./rfc5741#section-2">Section&nbsp;2 of RFC 5741</a>.
35
36 Information about the current status of this document, any errata,
37 and how to provide feedback on it may be obtained at
38 <a href="http://www.rfc-editor.org/info/rfc6287">http://www.rfc-editor.org/info/rfc6287</a>.
39
40 Copyright Notice
41
42 Copyright (c) 2011 IETF Trust and the persons identified as the
43 document authors. All rights reserved.
44
45 This document is subject to <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a> and the IETF Trust's Legal
46 Provisions Relating to IETF Documents
47 (<a href="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</a>) in effect on the date of
48 publication of this document. Please review these documents
49
50
51
52 <span class="grey">M'Raihi, et al. Informational [Page 1]</span></pre>
53 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span>
54 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
55
56
57 carefully, as they describe your rights and restrictions with respect
58 to this document. Code Components extracted from this document must
59 include Simplified BSD License text as described in Section 4.e of
60 the Trust Legal Provisions and are provided without warranty as
61 described in the Simplified BSD License.
62
63 Table of Contents
64
65 <a href="#section-1">1</a>. Introduction ....................................................<a href="#page-3">3</a>
66 <a href="#section-2">2</a>. Notation and Terminology ........................................<a href="#page-3">3</a>
67 <a href="#section-3">3</a>. Algorithm Requirements ..........................................<a href="#page-3">3</a>
68 <a href="#section-4">4</a>. OCRA Background .................................................<a href="#page-4">4</a>
69 <a href="#section-4.1">4.1</a>. HOTP Algorithm .............................................<a href="#page-4">4</a>
70 <a href="#section-5">5</a>. Definition of OCRA ..............................................<a href="#page-5">5</a>
71 <a href="#section-5.1">5.1</a>. DataInput Parameters .......................................<a href="#page-5">5</a>
72 <a href="#section-5.2">5.2</a>. CryptoFunction .............................................<a href="#page-7">7</a>
73 <a href="#section-6">6</a>. The OCRASuite ...................................................<a href="#page-8">8</a>
74 <a href="#section-6.1">6.1</a>. Algorithm ..................................................<a href="#page-9">9</a>
75 <a href="#section-6.2">6.2</a>. CryptoFunction .............................................<a href="#page-9">9</a>
76 <a href="#section-6.3">6.3</a>. DataInput ..................................................<a href="#page-9">9</a>
77 <a href="#section-6.4">6.4</a>. OCRASuite Examples ........................................<a href="#page-10">10</a>
78 <a href="#section-7">7</a>. Algorithm Modes for Authentication .............................<a href="#page-10">10</a>
79 <a href="#section-7.1">7.1</a>. One-Way Challenge-Response ................................<a href="#page-11">11</a>
80 <a href="#section-7.2">7.2</a>. Mutual Challenge-Response .................................<a href="#page-12">12</a>
81 <a href="#section-7.3">7.3</a>. Algorithm Modes for Signature .............................<a href="#page-13">13</a>
82 <a href="#section-7.3.1">7.3.1</a>. Plain Signature ....................................<a href="#page-13">13</a>
83 <a href="#section-7.3.2">7.3.2</a>. Signature with Server Authentication ...............<a href="#page-14">14</a>
84 <a href="#section-8">8</a>. Security Considerations ........................................<a href="#page-16">16</a>
85 <a href="#section-8.1">8.1</a>. Security Analysis of OCRA .................................<a href="#page-16">16</a>
86 <a href="#section-8.2">8.2</a>. Implementation Considerations .............................<a href="#page-17">17</a>
87 <a href="#section-9">9</a>. Conclusion .....................................................<a href="#page-18">18</a>
88 <a href="#section-10">10</a>. Acknowledgements ..............................................<a href="#page-18">18</a>
89 <a href="#section-11">11</a>. References ....................................................<a href="#page-19">19</a>
90 <a href="#section-11.1">11.1</a>. Normative References .....................................<a href="#page-19">19</a>
91 <a href="#section-11.2">11.2</a>. Informative References ...................................<a href="#page-19">19</a>
92 <a href="#appendix-A">Appendix A</a>. Reference Implementation ..............................<a href="#page-20">20</a>
93 <a href="#appendix-B">Appendix B</a>. Test Vectors Generation ...............................<a href="#page-26">26</a>
94 <a href="#appendix-C">Appendix C</a>. Test Vectors ..........................................<a href="#page-33">33</a>
95 <a href="#appendix-C.1">C.1</a>. One-Way Challenge Response .................................<a href="#page-34">34</a>
96 <a href="#appendix-C.2">C.2</a>. Mutual Challenge-Response ..................................<a href="#page-35">35</a>
97 <a href="#appendix-C.3">C.3</a>. Plain Signature ............................................<a href="#page-37">37</a>
98
99
100
101
102
103
104
105
106
107
108 <span class="grey">M'Raihi, et al. Informational [Page 2]</span></pre>
109 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span>
110 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
111
112
113 <span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span>
114
115 The Initiative for Open Authentication (OATH) [<a href="#ref-OATH" title="&quot;OATH Vision&quot;">OATH</a>] has identified
116 several use cases and scenarios that require an asynchronous variant
117 to accommodate users who do not want to maintain a synchronized
118 authentication system. A commonly accepted method for this is to use
119 a challenge-response scheme.
120
121 Such a challenge-response mode of authentication is widely adopted in
122 the industry. Several vendors already offer software applications
123 and hardware devices implementing challenge-response -- but each of
124 those uses vendor-specific proprietary algorithms. For the benefits
125 of users there is a need for a standardized challenge-response
126 algorithm that allows multi-sourcing of token purchases and
127 validation systems to facilitate the democratization of strong
128 authentication.
129
130 Additionally, this specification describes the means to create
131 symmetric key-based short 'electronic signatures'. Such signatures
132 are variants of challenge-response mode where the data to be signed
133 becomes the challenge or is used to derive the challenge. Note that
134 the term 'electronic signature' and 'signature' are used
135 interchangeably in this document.
136
137 <span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Notation and Terminology</span>
138
139 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
140 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
141 document are to be interpreted as described in [<a href="./rfc2119" title="&quot;Key words for use in RFCs to Indicate Requirement Levels&quot;">RFC2119</a>].
142
143 <span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. Algorithm Requirements</span>
144
145 This section presents the main requirements that drove this algorithm
146 design. A lot of emphasis was placed on flexibility and usability,
147 under the constraints and specificity of the HMAC-based One-Time
148 Password (HOTP) algorithm [<a href="./rfc4226" title="&quot;HOTP: An HMAC-Based One-Time Password Algorithm&quot;">RFC4226</a>] and hardware token capabilities.
149
150 R1 - The algorithm MUST support challenge-response-based
151 authentication.
152
153 R2 - The algorithm MUST be capable of supporting symmetric key-based
154 short electronic signatures. Essentially, this is a variation of
155 challenge-response where the challenge is derived from the data that
156 needs to be signed.
157
158 R3 - The algorithm MUST be capable of supporting server
159 authentication, whereby the user can verify that he/she is talking to
160 a trusted server.
161
162
163
164 <span class="grey">M'Raihi, et al. Informational [Page 3]</span></pre>
165 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span>
166 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
167
168
169 R4 - The algorithm SHOULD use HOTP [<a href="./rfc4226" title="&quot;HOTP: An HMAC-Based One-Time Password Algorithm&quot;">RFC4226</a>] as a key building block.
170
171 R5 - The length and format of the input challenge SHOULD be
172 configurable.
173
174 R6 - The output length and format of the generated response SHOULD be
175 configurable.
176
177 R7 - The challenge MAY be generated with integrity checking (e.g.,
178 parity bits). This will allow tokens with pin pads to perform simple
179 error checking when the user enters the challenge value into a token.
180
181 R8 - There MUST be a unique secret (key) for each token/soft token
182 that is shared between the token and the authentication server. The
183 keys MUST be randomly generated or derived using a key derivation
184 algorithm.
185
186 R9 - The algorithm MAY enable additional data attributes such as a
187 timestamp or session information to be included in the computation.
188 These data inputs MAY be used individually or all together.
189
190 <span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. OCRA Background</span>
191
192 OATH introduced the HOTP algorithm as a first open, freely available
193 building block towards strengthening authentication for end-users in
194 a variety of applications. One-time passwords are very efficient at
195 solving specific security issues thanks to the dynamic nature of OTP
196 computations.
197
198 After carefully analyzing different use cases, OATH came to the
199 conclusion that providing for extensions to the HOTP algorithms was
200 important. A very natural extension is to introduce a challenge mode
201 for computing HOTP values based on random questions. Equally
202 beneficial is being able to perform mutual authentication between two
203 parties, or short-signature computation for authenticating
204 transaction to improve the security of e-commerce applications.
205
206 <span class="h3"><a class="selflink" id="section-4.1" href="#section-4.1">4.1</a>. HOTP Algorithm</span>
207
208 The HOTP algorithm, as defined in [<a href="./rfc4226" title="&quot;HOTP: An HMAC-Based One-Time Password Algorithm&quot;">RFC4226</a>], is based on an
209 increasing counter value and a static symmetric key known only to the
210 prover and verifier parties.
211
212 As a reminder:
213 HOTP(K,C) = Truncate(HMAC-SHA1(K,C))
214
215 where Truncate represents the function that converts an HMAC-SHA-1
216 value into an HOTP value.
217
218
219
220 <span class="grey">M'Raihi, et al. Informational [Page 4]</span></pre>
221 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span>
222 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
223
224
225 We refer the reader to [<a href="./rfc4226" title="&quot;HOTP: An HMAC-Based One-Time Password Algorithm&quot;">RFC4226</a>] for the full description and further
226 details on the rationale and security analysis of HOTP.
227
228 The present document describes the different variants based on
229 similar constructions as HOTP.
230
231 <span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Definition of OCRA</span>
232
233 The OATH Challenge-Response Algorithm (OCRA) is a generalization of
234 HOTP with variable data inputs not solely based on an incremented
235 counter and secret key values.
236
237 The definition of OCRA requires a cryptographic function, a key K and
238 a set of DataInput parameters. This section first formally
239 introduces OCRA and then introduces the definitions and default
240 values recommended for all parameters.
241
242 In a nutshell,
243 OCRA = CryptoFunction(K, DataInput)
244
245 where:
246
247 o K: a shared secret key known to both parties
248
249 o DataInput: a structure that contains the concatenation of the
250 various input data values defined in details in <a href="#section-5.1">section 5.1</a>
251
252 o CryptoFunction: this is the function performing the OCRA
253 computation from the secret key K and the DataInput material;
254
255 CryptoFunction is described in details in <a href="#section-5.2">Section 5.2</a>
256
257 <span class="h3"><a class="selflink" id="section-5.1" href="#section-5.1">5.1</a>. DataInput Parameters</span>
258
259 This structure is the concatenation over byte array of the OCRASuite
260 value as defined in <a href="#section-6">section 6</a> with the different parameters used in
261 the computation, save for the secret key K.
262
263 DataInput = {OCRASuite | 00 | C | Q | P | S | T} where:
264
265 o OCRASuite is a value representing the suite of operations to
266 compute an OCRA response
267
268 o 00 is a byte value used as a separator
269
270
271
272
273
274
275
276 <span class="grey">M'Raihi, et al. Informational [Page 5]</span></pre>
277 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span>
278 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
279
280
281 o C is an unsigned 8-byte counter value processed high-order bit
282 first, and MUST be synchronized between all parties; It loops
283 around from "{Hex}0" to "{Hex}FFFFFFFFFFFFFFFF" and then starts
284 over at "{Hex}0". Note that 'C' is optional for all OCRA modes
285 described in this document.
286
287 o Q, mandatory, is a 128-byte list of (concatenated) challenge
288 question(s) generated by the parties; if Q is less than 128 bytes,
289 then it should be padded with zeroes to the right
290
291 o P is a hash (SHA-1 [<a href="./rfc3174" title="&quot;US Secure Hash Algorithm 1 (SHA1)&quot;">RFC3174</a>], SHA-256 and SHA-512 [<a href="#ref-SHA2" title="&quot;FIPS PUB 180-3: Secure Hash Standard (SHS)&quot;">SHA2</a>] are
292 supported) value of PIN/password that is known to all parties
293 during the execution of the algorithm; the length of P will depend
294 on the hash function that is used
295
296 o S is a UTF-8 [<a href="./rfc3629" title="&quot;UTF-8, a transformation format of ISO 10646&quot;">RFC3629</a>] encoded string of length up to 512 bytes
297 that contains information about the current session; the length of
298 S is defined in the OCRASuite string
299
300 o T is an 8-byte unsigned integer in big-endian order (i.e., network
301 byte order) representing the number of time-steps (seconds,
302 minutes, hours, or days depending on the specified granularity)
303 since midnight UTC of January 1, 1970 [<a href="#ref-UT" title="&quot;Unix time&quot;">UT</a>]. More specifically, if
304 the OCRA computation includes a timestamp T, you should first
305 convert your current local time to UTC time; you can then derive
306 the UTC time in the proper format (i.e., seconds, minutes, hours,
307 or days elapsed from epoch time); the size of the time-step is
308 specified in the OCRASuite string as described in <a href="#section-6.3">Section 6.3</a>
309
310 When computing a response, the concatenation order is always the
311 following:
312
313 C |
314
315 OTHER-PARTY-GENERATED-CHALLENGE-QUESTION |
316
317 YOUR-GENERATED-CHALLENGE-QUESTION |
318
319 P| S | T
320
321 If a value is empty (i.e., a certain input is not used in the
322 computation) then the value is simply not represented in the string.
323
324 The counter on the token or client MUST be incremented every time a
325 new computation is requested by the user. The server's counter value
326 MUST only be incremented after a successful OCRA authentication.
327
328
329
330
331
332 <span class="grey">M'Raihi, et al. Informational [Page 6]</span></pre>
333 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span>
334 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
335
336
337 <span class="h3"><a class="selflink" id="section-5.2" href="#section-5.2">5.2</a>. CryptoFunction</span>
338
339 The default CryptoFunction is HOTP-SHA1-6, i.e., the default mode of
340 computation for OCRA is HOTP with the default 6-digit dynamic
341 truncation and a combination of DataInput values as the message to
342 compute the HMAC-SHA1 digest.
343
344 We denote t as the length in decimal digits of the truncation output.
345 For instance, if t = 6, then the output of the truncation is a
346 6-digit (decimal) value.
347
348 We define the HOTP family of functions as an extension to HOTP:
349
350 1. HOTP-H-t: these are the different possible truncated versions of
351 HOTP, using the dynamic truncation method for extracting an HOTP
352 value from the HMAC output
353
354 2. We will denote HOTP-H-t as the realization of an HOTP function
355 that uses an HMAC function with the hash function H, and the
356 dynamic truncation as described in [<a href="./rfc4226" title="&quot;HOTP: An HMAC-Based One-Time Password Algorithm&quot;">RFC4226</a>] to extract a t-digit
357 value
358
359 3. t=0 means that no truncation is performed and the full HMAC value
360 is used for authentication purposes
361
362 We list the following preferred modes of computation, where * denotes
363 the default CryptoFunction:
364
365 o HOTP-SHA1-4: HOTP with SHA-1 as the hash function for HMAC and a
366 dynamic truncation to a 4-digit value; this mode is not
367 recommended in the general case, but it can be useful when a very
368 short authentication code is needed by an application
369
370 o HOTP-SHA1-6: HOTP with SHA-1 as the hash function for HMAC and a
371 dynamic truncation to a 6-digit value
372
373 o HOTP-SHA1-8: HOTP with SHA-1 as the hash function for HMAC and a
374 dynamic truncation to an 8-digit value
375
376 o HOTP-SHA256-6: HOTP with SHA-256 as the hash function for HMAC and
377 a dynamic truncation to a 6-digit value
378
379 o HOTP-SHA512-6: HOTP with SHA-512 as the hash function for HMAC and
380 a dynamic truncation to a 6-digit value
381
382
383
384
385
386
387
388 <span class="grey">M'Raihi, et al. Informational [Page 7]</span></pre>
389 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span>
390 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
391
392
393 This table summarizes all possible values for the CryptoFunction:
394
395 +---------------+--------------------+-------------------------+
396 | Name | HMAC Function Used | Size of Truncation (t) |
397 +---------------+--------------------+-------------------------+
398 | HOTP-SHA1-t | HMAC-SHA1 | 0 (no truncation), 4-10 |
399 | HOTP-SHA256-t | HMAC-SHA256 | 0 (no truncation), 4-10 |
400 | HOTP-SHA512-t | HMAC-SHA512 | 0 (no truncation), 4-10 |
401 +---------------+--------------------+-------------------------+
402
403 Table 1: CryptoFunction Table
404
405 <span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. The OCRASuite</span>
406
407 An OCRASuite value is a text string that captures one mode of
408 operation for OCRA, completely specifying the various options for
409 that computation. An OCRASuite value is represented as follows:
410
411 &lt;Algorithm&gt;:&lt;CryptoFunction&gt;:&lt;DataInput&gt;
412
413
414 The OCRASuite value is the concatenation of three sub-components that
415 are described below. Some example OCRASuite strings are described in
416 <a href="#section-6.4">Section 6.4</a>.
417
418 The client and server need to agree on one or two values of
419 OCRASuite. These values may be agreed upon at the time of token
420 provisioning or, for more sophisticated client-server interactions,
421 these values may be negotiated for every transaction.
422
423 The provisioning of OCRA keys and related metadata such as OCRASuite
424 is out of scope for this document. [<a href="./rfc6030" title="&quot;Portable Symmetric Key Container (PSKC)&quot;">RFC6030</a>] specifies one key
425 container specification that facilitates provisioning of such data
426 between the client and the server.
427
428 Note that for Mutual Challenge-Response or Signature with Server
429 Authentication modes, the client and server will need to agree on two
430 values of OCRASuite -- one for server computation and another for
431 client computation.
432
433
434
435
436
437
438
439
440
441
442
443
444 <span class="grey">M'Raihi, et al. Informational [Page 8]</span></pre>
445 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span>
446 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
447
448
449 <span class="h3"><a class="selflink" id="section-6.1" href="#section-6.1">6.1</a>. Algorithm</span>
450
451 Description: Indicates the version of OCRA.
452
453 Values: OCRA-v where v represents the version number (e.g., 1, 2).
454 This document specifies version 1 of OCRA.
455
456 <span class="h3"><a class="selflink" id="section-6.2" href="#section-6.2">6.2</a>. CryptoFunction</span>
457
458 Description: Indicates the function used to compute OCRA values
459
460 Values: Permitted values are described in <a href="#section-5.2">Section 5.2</a>.
461
462 <span class="h3"><a class="selflink" id="section-6.3" href="#section-6.3">6.3</a>. DataInput</span>
463
464 Description: This component of the OCRASuite string captures the list
465 of valid inputs for that computation; [] indicates a value is
466 optional:
467
468 [<a id="ref-C">C</a>] | QFxx | [PH | Snnn | TG] : Challenge-Response computation
469
470 [<a id="ref-C">C</a>] | QFxx | [PH | TG] : Plain Signature computation
471
472 Each input that is used for the computation is represented by a
473 single letter (except Q), and they are separated by a hyphen.
474
475 The input for challenge is further qualified by the formats supported
476 by the client for challenge question(s). Supported values can be:
477
478 +------------------+-------------------+
479 | Format (F) | Up to Length (xx) |
480 +------------------+-------------------+
481 | A (alphanumeric) | 04-64 |
482 | N (numeric) | 04-64 |
483 | H (hexadecimal) | 04-64 |
484 +------------------+-------------------+
485
486 Table 2: Challenge Format Table
487
488 The default challenge format is N08, numeric and up to 8 digits.
489
490 The input for P is further qualified by the hash function used for
491 the PIN/password. Supported values for hash function can be:
492
493 Hash function (H) - SHA1, SHA256, SHA512.
494
495 The default hash function for P is SHA1.
496
497
498
499
500 <span class="grey">M'Raihi, et al. Informational [Page 9]</span></pre>
501 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span>
502 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
503
504
505 The input for S is further qualified by the length of the session
506 data in bytes. The client and server could agree to any length but
507 the typical values are:
508
509 Length (nnn) - 064, 128, 256, and 512.
510
511 The default length is 064 bytes.
512
513 The input for timestamps is further qualified by G, size of the time-
514 step. G can be specified in number of seconds, minutes, or hours:
515
516 +--------------------+------------------------------+
517 | Time-Step Size (G) | Examples |
518 +--------------------+------------------------------+
519 | [1-59]S | number of seconds, e.g., 20S |
520 | [1-59]M | number of minutes, e.g., 5M |
521 | [0-48]H | number of hours, e.g., 24H |
522 +--------------------+------------------------------+
523
524 Table 3: Time-step Size Table
525
526 Default value for G is 1M, i.e., time-step size is one minute and the
527 T represents the number of minutes since epoch time [<a href="#ref-UT" title="&quot;Unix time&quot;">UT</a>].
528
529 <span class="h3"><a class="selflink" id="section-6.4" href="#section-6.4">6.4</a>. OCRASuite Examples</span>
530
531 Here are some examples of OCRASuite strings:
532
533 o "OCRA-1:HOTP-SHA512-8:C-QN08-PSHA1" means version 1 of OCRA with
534 HMAC-SHA512 function, truncated to an 8-digit value, using the
535 counter, a random challenge, and a SHA1 digest of the PIN/password
536 as parameters. It also indicates that the client supports only
537 numeric challenge up to 8 digits in length
538
539 o "OCRA-1:HOTP-SHA256-6:QA10-T1M" means version 1 of OCRA with HMAC-
540 SHA256 function, truncated to a 6-digit value, using a random
541 alphanumeric challenge up to 10 characters in length and a
542 timestamp in number of minutes since epoch time
543
544 o "OCRA-1:HOTP-SHA1-4:QH8-S512" means version 1 of OCRA with HMAC-
545 SHA1 function, truncated to a 4-digit value, using a random
546 hexadecimal challenge up to 8 nibbles and a session value of 512
547 bytes
548
549 <span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. Algorithm Modes for Authentication</span>
550
551 This section describes the typical modes in which the above defined
552 computation can be used for authentication.
553
554
555
556 <span class="grey">M'Raihi, et al. Informational [Page 10]</span></pre>
557 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-11" ></span>
558 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
559
560
561 <span class="h3"><a class="selflink" id="section-7.1" href="#section-7.1">7.1</a>. One-Way Challenge-Response</span>
562
563 A challenge-response is a security mechanism in which the verifier
564 presents a question (challenge) to the prover, who must provide a
565 valid answer (response) to be authenticated.
566
567 To use this algorithm for a one-way challenge-response, the verifier
568 will communicate a challenge value (typically randomly generated) to
569 the prover. The prover will use the challenge in the computation as
570 described above. The prover then communicates the response to the
571 verifier to authenticate.
572
573 Therefore in this mode, the typical data inputs will be:
574
575 C - Counter, optional.
576
577 Q - Challenge question, mandatory, supplied by the verifier.
578
579 P - Hashed version of PIN/password, optional.
580
581 S - Session information, optional.
582
583 T - Timestamp, optional.
584
585 The diagram below shows the message exchange between the client
586 (prover) and the server (verifier) to complete a one-way challenge-
587 response authentication.
588
589 It is assumed that the client and server have a pre-shared key K that
590 is used for the computation.
591
592 CLIENT SERVER
593 (PROVER) VERIFIER)
594 | |
595 | Verifier sends challenge to prover |
596 | Challenge = Q |
597 |&lt;---------------------------------------|
598 | |
599 | Prover Computes Response |
600 | R = OCRA(K, {[<a href="#ref-C">C</a>] | Q | [P | S | T]}) |
601 | Prover sends Response = R |
602 |---------------------------------------&gt;|
603 | |
604 | Verifier Validates Response |
605 | If Response is valid, Server sends OK |
606 | If Response is not, Server sends NOK |
607 |&lt;---------------------------------------|
608 | |
609
610
611
612 <span class="grey">M'Raihi, et al. Informational [Page 11]</span></pre>
613 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-12" ></span>
614 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
615
616
617 <span class="h3"><a class="selflink" id="section-7.2" href="#section-7.2">7.2</a>. Mutual Challenge-Response</span>
618
619 Mutual challenge-response is a variation of one-way challenge-
620 response where both the client and server mutually authenticate each
621 other.
622
623 To use this algorithm, the client will first send a random client-
624 challenge to the server. The server computes the server-response and
625 sends it to the client along with a server-challenge.
626
627 The client will first verify the server-response to be assured that
628 it is talking to a valid server. It will then compute the client-
629 response and send it to the server to authenticate. The server
630 verifies the client-response to complete the two-way authentication
631 process.
632
633 In this mode there are two computations: client-response and server-
634 response. There are two separate challenge questions, generated by
635 both parties. We denote these challenge questions Q1 and Q2.
636
637 Typical data inputs for server-response computation will be:
638
639 C - Counter, optional.
640
641 QC - Challenge question, mandatory, supplied by the client.
642
643 QS - Challenge question, mandatory, supplied by the server.
644
645 S - Session information, optional.
646
647 T - Timestamp, optional.
648
649 Typical data inputs for client-response computation will be:
650
651 C - Counter, optional.
652
653 QS - Challenge question, mandatory, supplied by the server.
654
655 QC - Challenge question, mandatory, supplied by the client.
656
657 P - Hashed version of PIN/password, optional.
658
659 S - Session information, optional.
660
661 T - Timestamp, optional.
662
663
664
665
666
667
668 <span class="grey">M'Raihi, et al. Informational [Page 12]</span></pre>
669 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-13" ></span>
670 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
671
672
673 The following diagram shows the messages that are exchanged between
674 the client and the server to complete a two-way mutual challenge-
675 response authentication.
676
677 It is assumed that the client and server have a pre-shared key K (or
678 pair of keys if using dual-key mode of computation) that is used for
679 the computation.
680
681 CLIENT SERVER
682 (PROVER) (VERIFIER)
683 | |
684 | 1. Client sends client-challenge |
685 | QC = Client-challenge |
686 |-------------------------------------------------&gt;|
687 | |
688 | 2. Server computes server-response |
689 | and sends server-challenge |
690 | RS = OCRA(K, [<a href="#ref-C">C</a>] | QC | QS | [S | T]) |
691 | QS = Server-challenge |
692 | Response = RS, QS |
693 |&lt;-------------------------------------------------|
694 | |
695 | 3. Client verifies server-response |
696 | and computes client-response |
697 | OCRA(K, [<a href="#ref-C">C</a>] | QC | QS | [S | T]) != RS -&gt; STOP |
698 | RC = OCRA(K, [<a href="#ref-C">C</a>] | QS | QC | [P | S | T]) |
699 | Response = RC |
700 |-------------------------------------------------&gt;|
701 | |
702 | 4. Server verifies client-response |
703 | OCRA(K, [<a href="#ref-C">C</a>] | QS | QC | [P|S|T]) != RC -&gt; STOP |
704 | Response = OK |
705 |&lt;-------------------------------------------------|
706 | |
707
708 <span class="h3"><a class="selflink" id="section-7.3" href="#section-7.3">7.3</a>. Algorithm Modes for Signature</span>
709
710 In this section we describe the typical modes in which the above
711 defined computation can be used for electronic signatures.
712
713 <span class="h4"><a class="selflink" id="section-7.3.1" href="#section-7.3.1">7.3.1</a>. Plain Signature</span>
714
715 To use this algorithm in plain signature mode, the server will
716 communicate a signature-challenge value to the client (signer). The
717 signature-challenge is either the data to be signed or derived from
718 the data to be signed using a hash function, for example.
719
720
721
722
723
724 <span class="grey">M'Raihi, et al. Informational [Page 13]</span></pre>
725 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-14" ></span>
726 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
727
728
729 The client will use the signature-challenge in the computation as
730 described above. The client then communicates the signature value
731 (response) to the server to authenticate.
732
733 Therefore in this mode, the data inputs will be:
734
735 C - Counter, optional.
736
737 QS - Signature-challenge, mandatory, supplied by the server.
738
739 P - Hashed version of PIN/password, optional.
740
741 T - Timestamp, optional.
742
743 The picture below shows the messages that are exchanged between the
744 client (prover) and the server (verifier) to complete a plain
745 signature operation.
746
747 It is assumed that the client and server have a pre-shared key K that
748 is used for the computation.
749
750 CLIENT SERVER
751 (PROVER) (VERIFIER)
752 | |
753 | Verifier sends signature-challenge |
754 | Challenge = QS |
755 |&lt;------------------------------------------|
756 | |
757 | Client Computes Response |
758 | SIGN = OCRA(K, [<a href="#ref-C">C</a>] | QS | [P | T]) |
759 | Response = SIGN |
760 |------------------------------------------&gt;|
761 | |
762 | Verifier Validates Response |
763 | Response = OK |
764 |&lt;------------------------------------------|
765 | |
766
767 <span class="h4"><a class="selflink" id="section-7.3.2" href="#section-7.3.2">7.3.2</a>. Signature with Server Authentication</span>
768
769 This mode is a variation of the plain signature mode where the client
770 can first authenticate the server before generating a electronic
771 signature.
772
773 To use this algorithm, the client will first send a random client-
774 challenge to the server. The server computes the server-response and
775 sends it to the client along with a signature-challenge.
776
777
778
779
780 <span class="grey">M'Raihi, et al. Informational [Page 14]</span></pre>
781 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-15" ></span>
782 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
783
784
785 The client will first verify the server-response to authenticate that
786 it is talking to a valid server. It will then compute the signature
787 and send it to the server.
788
789 In this mode there are two computations: client-signature and server-
790 response.
791
792 Typical data inputs for server-response computation will be:
793
794 C - Counter, optional.
795
796 QC - Challenge question, mandatory, supplied by the client.
797
798 QS - Signature-challenge, mandatory, supplied by the server.
799
800 T - Timestamp, optional.
801
802 Typical data inputs for client-signature computation will be:
803
804 C - Counter, optional.
805
806 QC - Challenge question, mandatory, supplied by the client.
807
808 QS - Signature-challenge, mandatory, supplied by the server.
809
810 P - Hashed version of PIN/password, optional.
811
812 T - Timestamp, optional.
813
814 The diagram below shows the messages that are exchanged between the
815 client and the server to complete a signature with server
816 authentication transaction.
817
818 It is assumed that the client and server have a pre-shared key K (or
819 pair of keys if using dual-key mode of computation) that is used for
820 the computation.
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836 <span class="grey">M'Raihi, et al. Informational [Page 15]</span></pre>
837 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-16" ></span>
838 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
839
840
841 CLIENT SERVER
842 (PROVER) VERIFIER)
843 | |
844 | 1. Client sends client-challenge |
845 | QC = Client-challenge |
846 |--------------------------------------------------&gt;|
847 | |
848 | 2. Server computes server-response |
849 | and sends signature-challenge |
850 | RS = OCRA(K, [<a href="#ref-C">C</a>] | QC | QS | [T]) |
851 | QS = signature-challenge |
852 | Response = RS, QS |
853 |&lt;--------------------------------------------------|
854 | |
855 | 3. Client verifies server-response |
856 | and computes signature |
857 | OCRA(K, [<a href="#ref-C">C</a>] | QC | QS | [T]) != RS -&gt; STOP |
858 | SIGN = OCRA( K, [<a href="#ref-C">C</a>] | QS | QC | [P | T]) |
859 | Response = SIGN |
860 |--------------------------------------------------&gt;|
861 | |
862 | 4. Server verifies Signature |
863 | OCRA(K, [<a href="#ref-C">C</a>] | QS | QC | [P|T]) != SIGN -&gt; STOP |
864 | Response = OK |
865 |&lt;--------------------------------------------------|
866 | |
867
868 <span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. Security Considerations</span>
869
870 Any algorithm is only as secure as the application and the
871 authentication protocols that implement it. Therefore, this section
872 discusses the critical security requirements that our choice of
873 algorithm imposes on the authentication protocol and validation
874 software.
875
876 <span class="h3"><a class="selflink" id="section-8.1" href="#section-8.1">8.1</a>. Security Analysis of OCRA</span>
877
878 The security and strength of this algorithm depend on the properties
879 of the underlying building block HOTP, which is a construction based
880 on HMAC [<a href="./rfc2104" title="&quot;HMAC: Keyed- Hashing for Message Authentication&quot;">RFC2104</a>] using SHA-1 [<a href="./rfc3174" title="&quot;US Secure Hash Algorithm 1 (SHA1)&quot;">RFC3174</a>] (or SHA-256 or SHA-512
881 [<a href="#ref-SHA2" title="&quot;FIPS PUB 180-3: Secure Hash Standard (SHS)&quot;">SHA2</a>]) as the hash function.
882
883 The conclusion of the security analysis detailed in [<a href="./rfc4226" title="&quot;HOTP: An HMAC-Based One-Time Password Algorithm&quot;">RFC4226</a>] is
884 that, for all practical purposes, the outputs of the dynamic
885 truncation on distinct counter inputs are uniformly and independently
886 distributed strings.
887
888
889
890
891
892 <span class="grey">M'Raihi, et al. Informational [Page 16]</span></pre>
893 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-17" ></span>
894 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
895
896
897 The analysis demonstrates that the best possible attack against the
898 HOTP function is the brute force attack.
899
900 <span class="h3"><a class="selflink" id="section-8.2" href="#section-8.2">8.2</a>. Implementation Considerations</span>
901
902 IC1 - In the authentication mode, the client MUST support two-factor
903 authentication, i.e., the communication and verification of something
904 you know (secret code such as a password, pass phrase, PIN code,
905 etc.) and something you have (token). The secret code is known only
906 to the user and usually entered with the Response value for
907 authentication purpose (two-factor authentication). Alternatively,
908 instead of sending something you know to the server, the client may
909 use a hash of the password or PIN code in the computation itself,
910 thus implicitly enabling two-factor authentication.
911
912 IC2 - Keys SHOULD be of the length of the CryptoFunction output to
913 facilitate interoperability.
914
915 IC3 - Keys SHOULD be chosen at random or using a cryptographically
916 strong pseudo-random generator properly seeded with a random value.
917 We RECOMMEND following the recommendations in [<a href="./rfc4086" title="&quot;Randomness Requirements for Security&quot;">RFC4086</a>] for all
918 pseudo-random and random generations. The pseudo-random numbers used
919 for generating the keys SHOULD successfully pass the randomness test
920 specified in [<a href="#ref-CN" title="&quot;An accurate evaluation of Maurer's universal test&quot;">CN</a>].
921
922 IC4 - Challenge questions SHOULD be 20-byte values and MUST be at
923 least t-byte values where t stands for the digit-length of the OCRA
924 truncation output.
925
926 IC5 - On the client side, the keys SHOULD be embedded in a tamper-
927 resistant device or securely implemented in a software application.
928 Additionally, by embedding the keys in a hardware device, you also
929 have the advantage of improving the flexibility (mobility) of the
930 authentication system.
931
932 IC6 - All the communications SHOULD take place over a secure channel,
933 e.g., SSL/TLS [<a href="./rfc5246" title="&quot;The Transport Layer Security (TLS) Protocol Version 1.2&quot;">RFC5246</a>], IPsec connections.
934
935 IC7 - OCRA, when used in mutual authentication mode or in signature
936 with server authentication mode, MAY use dual-key mode -- i.e., there
937 are two keys that are shared between the client and the server. One
938 shared key is used to generate the server response on the server side
939 and to verify it on the client side. The other key is used to create
940 the response or signature on the client side and to verify it on the
941 server side.
942
943
944
945
946
947
948 <span class="grey">M'Raihi, et al. Informational [Page 17]</span></pre>
949 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-18" ></span>
950 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
951
952
953 IC8 - We recommend that implementations MAY use the session
954 information, S, as an additional input in the computation. For
955 example, S could be the session identifier from the TLS session.
956
957 This will mitigate against certain types of man-in-the-middle
958 attacks. However, this will introduce the additional dependency that
959 first of all the prover needs to have access to the session
960 identifier to compute the response and the verifier will need access
961 to the session identifier to verify the response. [<a href="./rfc5056" title="&quot;On the Use of Channel Bindings to Secure Channels&quot;">RFC5056</a>] contains
962 a relevant discussion of using Channel Bindings to Secure Channels.
963
964 IC9 - In the signature mode, whenever the counter or time (defined as
965 optional elements) are not used in the computation, there might be a
966 risk of replay attack and the implementers should carefully consider
967 this issue in the light of their specific application requirements
968 and security guidelines. The server SHOULD also provide whenever
969 possible a mean for the client (if able) to verify the validity of
970 the signature challenge.
971
972 IC10 - We also RECOMMEND storing the keys securely in the validation
973 system, and more specifically, encrypting them using tamper-resistant
974 hardware encryption and exposing them only when required: for
975 example, the key is decrypted when needed to verify an OCRA response,
976 and re-encrypted immediately to limit exposure in the RAM for a short
977 period of time. The key store MUST be in a secure area, to avoid as
978 much as possible direct attack on the validation system and secrets
979 database. Particularly, access to the key material should be limited
980 to programs and processes required by the validation system only.
981
982 <span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. Conclusion</span>
983
984 This document introduced several variants of HOTP for challenge-
985 response-based authentication and short signature-like computations.
986
987 The OCRASuite provides for an easy integration and support of
988 different flavors within an authentication and validation system.
989
990 Finally, OCRA should enable mutual authentication both in connected
991 and off-line modes, with the support of different response sizes and
992 mode of operations.
993
994 <span class="h2"><a class="selflink" id="section-10" href="#section-10">10</a>. Acknowledgements</span>
995
996 We would like to thank Jeff Burstein, Shuh Chang, Oanh Hoang, Philip
997 Hoyer, Jon Martinsson, Frederik Mennes, Mingliang Pei, Jonathan
998 Tuliani, Stu Vaeth, Enrique Rodriguez, and Robert Zuccherato for
999 their comments and suggestions to improve this document.
1000
1001
1002
1003
1004 <span class="grey">M'Raihi, et al. Informational [Page 18]</span></pre>
1005 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-19" ></span>
1006 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1007
1008
1009 <span class="h2"><a class="selflink" id="section-11" href="#section-11">11</a>. References</span>
1010
1011 <span class="h3"><a class="selflink" id="section-11.1" href="#section-11.1">11.1</a>. Normative References</span>
1012
1013 [<a id="ref-RFC2104">RFC2104</a>] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed-
1014 Hashing for Message Authentication", <a href="./rfc2104">RFC 2104</a>,
1015 February 1997.
1016
1017 [<a id="ref-RFC2119">RFC2119</a>] Bradner, S., "Key words for use in RFCs to Indicate
1018 Requirement Levels", <a href="https://www.rfc-editor.org/bcp/bcp14">BCP 14</a>, <a href="./rfc2119">RFC 2119</a>, March 1997.
1019
1020 [<a id="ref-RFC3174">RFC3174</a>] Eastlake, D. and P. Jones, "US Secure Hash Algorithm 1
1021 (SHA1)", <a href="./rfc3174">RFC 3174</a>, September 2001.
1022
1023 [<a id="ref-RFC3629">RFC3629</a>] Yergeau, F., "UTF-8, a transformation format of ISO
1024 10646", STD 63, <a href="./rfc3629">RFC 3629</a>, November 2003.
1025
1026 [<a id="ref-RFC4086">RFC4086</a>] Eastlake, D., Schiller, J., and S. Crocker, "Randomness
1027 Requirements for Security", <a href="https://www.rfc-editor.org/bcp/bcp106">BCP 106</a>, <a href="./rfc4086">RFC 4086</a>, June 2005.
1028
1029 [<a id="ref-RFC4226">RFC4226</a>] M'Raihi, D., Bellare, M., Hoornaert, F., Naccache, D., and
1030 O. Ranen, "HOTP: An HMAC-Based One-Time Password
1031 Algorithm", <a href="./rfc4226">RFC 4226</a>, December 2005.
1032
1033 [<a id="ref-SHA2">SHA2</a>] NIST, "FIPS PUB 180-3: Secure Hash Standard (SHS)",
1034 October 2008, &lt;<a href="http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf">http://csrc.nist.gov/publications/fips/</a>
1035 <a href="http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf">fips180-3/fips180-3_final.pdf</a>&gt;.
1036
1037 <span class="h3"><a class="selflink" id="section-11.2" href="#section-11.2">11.2</a>. Informative References</span>
1038
1039 [<a id="ref-CN">CN</a>] Coron, J. and D. Naccache, "An accurate evaluation of
1040 Maurer's universal test", LNCS 1556, February 1999, &lt;http:
1041 //www.gemplus.com/smart/rd/publications/pdf/CN99maur.pdf&gt;.
1042
1043 [<a id="ref-OATH">OATH</a>] Initiative for Open Authentication, "OATH Vision",
1044 &lt;<a href="http://www.openauthentication.org/about">http://www.openauthentication.org/about</a>&gt;.
1045
1046 [<a id="ref-RFC5056">RFC5056</a>] Williams, N., "On the Use of Channel Bindings to Secure
1047 Channels", <a href="./rfc5056">RFC 5056</a>, November 2007.
1048
1049 [<a id="ref-RFC5246">RFC5246</a>] Dierks, T. and E. Rescorla, "The Transport Layer Security
1050 (TLS) Protocol Version 1.2", <a href="./rfc5246">RFC 5246</a>, August 2008.
1051
1052 [<a id="ref-RFC6030">RFC6030</a>] Hoyer, P., Pei, M., and S. Machani, "Portable Symmetric
1053 Key Container (PSKC)", <a href="./rfc6030">RFC 6030</a>, October 2010.
1054
1055 [<a id="ref-UT">UT</a>] Wikipedia, "Unix time",
1056 &lt;<a href="http://en.wikipedia.org/wiki/Unix_time">http://en.wikipedia.org/wiki/Unix_time</a>&gt;.
1057
1058
1059
1060 <span class="grey">M'Raihi, et al. Informational [Page 19]</span></pre>
1061 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-20" ></span>
1062 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1063
1064
1065 <span class="h2"><a class="selflink" id="appendix-A" href="#appendix-A">Appendix A</a>. Reference Implementation</span>
1066
1067 &lt;CODE BEGINS&gt;
1068
1069 /**
1070 Copyright (c) 2011 IETF Trust and the persons identified as
1071 authors of the code. All rights reserved.
1072
1073 Redistribution and use in source and binary forms, with or without
1074 modification, is permitted pursuant to, and subject to the license
1075 terms contained in, the Simplified BSD License set forth in <a href="#section-4">Section</a>
1076 <a href="#section-4">4</a>.c of the IETF Trust's Legal Provisions Relating to IETF Documents
1077 (<a href="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</a>).
1078 */
1079
1080 import javax.crypto.Mac;
1081 import javax.crypto.spec.SecretKeySpec;
1082 import java.math.BigInteger;
1083
1084 /**
1085 * This an example implementation of OCRA.
1086 * Visit www.openauthentication.org for more information.
1087 *
1088 * @author Johan Rydell, PortWise
1089 */
1090 public class OCRA {
1091
1092 private OCRA() {}
1093
1094 /**
1095 * This method uses the JCE to provide the crypto
1096 * algorithm.
1097 * HMAC computes a Hashed Message Authentication Code with the
1098 * crypto hash algorithm as a parameter.
1099 *
1100 * @param crypto the crypto algorithm (HmacSHA1, HmacSHA256,
1101 * HmacSHA512)
1102 * @param keyBytes the bytes to use for the HMAC key
1103 * @param text the message or text to be authenticated.
1104 */
1105
1106 private static byte[] hmac_sha1(String crypto,
1107 byte[] keyBytes, byte[] text){
1108 Mac hmac = null;
1109 try {
1110 hmac = Mac.getInstance(crypto);
1111 SecretKeySpec macKey =
1112 new SecretKeySpec(keyBytes, "RAW");
1113
1114
1115
1116 <span class="grey">M'Raihi, et al. Informational [Page 20]</span></pre>
1117 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-21" ></span>
1118 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1119
1120
1121 hmac.init(macKey);
1122 return hmac.doFinal(text);
1123 } catch (Exception e) {
1124 e.printStackTrace();
1125 }
1126 return null;
1127 }
1128
1129
1130 private static final int[] DIGITS_POWER
1131 // 0 1 2 3 4 5 6 7 8
1132 = {1,10,100,1000,10000,100000,1000000,10000000,100000000 };
1133
1134 /**
1135 * This method converts HEX string to Byte[]
1136 *
1137 * @param hex the HEX string
1138 *
1139 * @return A byte array
1140 */
1141 private static byte[] hexStr2Bytes(String hex){
1142 // Adding one byte to get the right conversion
1143 // values starting with "0" can be converted
1144 byte[] bArray = new BigInteger("10" + hex,16).toByteArray();
1145
1146 // Copy all the REAL bytes, not the "first"
1147 byte[] ret = new byte[bArray.length - 1];
1148 System.arraycopy(bArray, 1, ret, 0, ret.length);
1149 return ret;
1150 }
1151
1152
1153 /**
1154 * This method generates an OCRA HOTP value for the given
1155 * set of parameters.
1156 *
1157 * @param ocraSuite the OCRA Suite
1158 * @param key the shared secret, HEX encoded
1159 * @param counter the counter that changes on a per use
1160 * basis, HEX encoded
1161 * @param question the challenge question, HEX encoded
1162 * @param password a password that can be used, HEX encoded
1163 * @param sessionInformation Static information that identifies
1164 * the current session, Hex encoded
1165 * @param timeStamp a value that reflects a time
1166 *
1167 * @return A numeric String in base 10 that includes
1168 * {@link truncationDigits} digits
1169
1170
1171
1172 <span class="grey">M'Raihi, et al. Informational [Page 21]</span></pre>
1173 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-22" ></span>
1174 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1175
1176
1177 */
1178 static public String generateOCRA(String ocraSuite,
1179 String key,
1180 String counter,
1181 String question,
1182 String password,
1183 String sessionInformation,
1184 String timeStamp){
1185
1186 int codeDigits = 0;
1187 String crypto = "";
1188 String result = null;
1189 int ocraSuiteLength = (ocraSuite.getBytes()).length;
1190 int counterLength = 0;
1191 int questionLength = 0;
1192 int passwordLength = 0;
1193 int sessionInformationLength = 0;
1194 int timeStampLength = 0;
1195
1196 // The OCRASuites components
1197 String CryptoFunction = ocraSuite.split(":")[1];
1198 String DataInput = ocraSuite.split(":")[2];
1199
1200
1201 if(CryptoFunction.toLowerCase().indexOf("sha1") &gt; 1)
1202 crypto = "HmacSHA1";
1203 if(CryptoFunction.toLowerCase().indexOf("sha256") &gt; 1)
1204 crypto = "HmacSHA256";
1205 if(CryptoFunction.toLowerCase().indexOf("sha512") &gt; 1)
1206 crypto = "HmacSHA512";
1207
1208 // How many digits should we return
1209 codeDigits = Integer.decode(CryptoFunction.substring(
1210 CryptoFunction.lastIndexOf("-")+1));
1211
1212 // The size of the byte array message to be encrypted
1213 // Counter
1214 if(DataInput.toLowerCase().startsWith("c")) {
1215 // Fix the length of the HEX string
1216 while(counter.length() &lt; 16)
1217 counter = "0" + counter;
1218 counterLength=8;
1219 }
1220 // Question - always 128 bytes
1221 if(DataInput.toLowerCase().startsWith("q") ||
1222 (DataInput.toLowerCase().indexOf("-q") &gt;= 0)) {
1223 while(question.length() &lt; 256)
1224 question = question + "0";
1225
1226
1227
1228 <span class="grey">M'Raihi, et al. Informational [Page 22]</span></pre>
1229 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-23" ></span>
1230 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1231
1232
1233 questionLength=128;
1234 }
1235
1236 // Password - sha1
1237 if(DataInput.toLowerCase().indexOf("psha1") &gt; 1){
1238 while(password.length() &lt; 40)
1239 password = "0" + password;
1240 passwordLength=20;
1241 }
1242
1243 // Password - sha256
1244 if(DataInput.toLowerCase().indexOf("psha256") &gt; 1){
1245 while(password.length() &lt; 64)
1246 password = "0" + password;
1247 passwordLength=32;
1248 }
1249
1250 // Password - sha512
1251 if(DataInput.toLowerCase().indexOf("psha512") &gt; 1){
1252 while(password.length() &lt; 128)
1253 password = "0" + password;
1254 passwordLength=64;
1255 }
1256
1257 // sessionInformation - s064
1258 if(DataInput.toLowerCase().indexOf("s064") &gt; 1){
1259 while(sessionInformation.length() &lt; 128)
1260 sessionInformation = "0" + sessionInformation;
1261 sessionInformationLength=64;
1262 }
1263
1264 // sessionInformation - s128
1265 if(DataInput.toLowerCase().indexOf("s128") &gt; 1){
1266 while(sessionInformation.length() &lt; 256)
1267 sessionInformation = "0" + sessionInformation;
1268 sessionInformationLength=128;
1269 }
1270
1271 // sessionInformation - s256
1272 if(DataInput.toLowerCase().indexOf("s256") &gt; 1){
1273 while(sessionInformation.length() &lt; 512)
1274 sessionInformation = "0" + sessionInformation;
1275 sessionInformationLength=256;
1276 }
1277
1278 // sessionInformation - s512
1279 if(DataInput.toLowerCase().indexOf("s512") &gt; 1){
1280 while(sessionInformation.length() &lt; 1024)
1281
1282
1283
1284 <span class="grey">M'Raihi, et al. Informational [Page 23]</span></pre>
1285 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-24" ></span>
1286 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1287
1288
1289 sessionInformation = "0" + sessionInformation;
1290 sessionInformationLength=512;
1291 }
1292
1293 // TimeStamp
1294 if(DataInput.toLowerCase().startsWith("t") ||
1295 (DataInput.toLowerCase().indexOf("-t") &gt; 1)){
1296 while(timeStamp.length() &lt; 16)
1297 timeStamp = "0" + timeStamp;
1298 timeStampLength=8;
1299 }
1300
1301 // Remember to add "1" for the "00" byte delimiter
1302 byte[] msg = new byte[ocraSuiteLength +
1303 counterLength +
1304 questionLength +
1305 passwordLength +
1306 sessionInformationLength +
1307 timeStampLength +
1308 1];
1309
1310
1311 // Put the bytes of "ocraSuite" parameters into the message
1312 byte[] bArray = ocraSuite.getBytes();
1313 System.arraycopy(bArray, 0, msg, 0, bArray.length);
1314
1315 // Delimiter
1316 msg[bArray.length] = 0x00;
1317
1318 // Put the bytes of "Counter" to the message
1319 // Input is HEX encoded
1320 if(counterLength &gt; 0 ){
1321 bArray = hexStr2Bytes(counter);
1322 System.arraycopy(bArray, 0, msg, ocraSuiteLength + 1,
1323 bArray.length);
1324 }
1325
1326
1327 // Put the bytes of "question" to the message
1328 // Input is text encoded
1329 if(questionLength &gt; 0 ){
1330 bArray = hexStr2Bytes(question);
1331 System.arraycopy(bArray, 0, msg, ocraSuiteLength + 1 +
1332 counterLength, bArray.length);
1333 }
1334
1335 // Put the bytes of "password" to the message
1336 // Input is HEX encoded
1337
1338
1339
1340 <span class="grey">M'Raihi, et al. Informational [Page 24]</span></pre>
1341 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-25" ></span>
1342 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1343
1344
1345 if(passwordLength &gt; 0){
1346 bArray = hexStr2Bytes(password);
1347 System.arraycopy(bArray, 0, msg, ocraSuiteLength + 1 +
1348 counterLength + questionLength, bArray.length);
1349
1350 }
1351
1352 // Put the bytes of "sessionInformation" to the message
1353 // Input is text encoded
1354 if(sessionInformationLength &gt; 0 ){
1355 bArray = hexStr2Bytes(sessionInformation);
1356 System.arraycopy(bArray, 0, msg, ocraSuiteLength + 1 +
1357 counterLength + questionLength +
1358 passwordLength, bArray.length);
1359 }
1360
1361 // Put the bytes of "time" to the message
1362 // Input is text value of minutes
1363 if(timeStampLength &gt; 0){
1364 bArray = hexStr2Bytes(timeStamp);
1365 System.arraycopy(bArray, 0, msg, ocraSuiteLength + 1 +
1366 counterLength + questionLength +
1367 passwordLength + sessionInformationLength,
1368 bArray.length);
1369 }
1370
1371 bArray = hexStr2Bytes(key);
1372
1373 byte[] hash = hmac_sha1(crypto, bArray, msg);
1374
1375 // put selected bytes into result int
1376 int offset = hash[hash.length - 1] &amp; 0xf;
1377
1378 int binary =
1379 ((hash[offset] &amp; 0x7f) &lt;&lt; 24) |
1380 ((hash[offset + 1] &amp; 0xff) &lt;&lt; 16) |
1381 ((hash[offset + 2] &amp; 0xff) &lt;&lt; 8) |
1382 (hash[offset + 3] &amp; 0xff);
1383
1384 int otp = binary % DIGITS_POWER[codeDigits];
1385
1386 result = Integer.toString(otp);
1387 while (result.length() &lt; codeDigits) {
1388 result = "0" + result;
1389 }
1390 return result;
1391 }
1392 }
1393
1394
1395
1396 <span class="grey">M'Raihi, et al. Informational [Page 25]</span></pre>
1397 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-26" ></span>
1398 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1399
1400
1401 &lt;CODE ENDS&gt;
1402
1403 <span class="h2"><a class="selflink" id="appendix-B" href="#appendix-B">Appendix B</a>. Test Vectors Generation</span>
1404
1405 &lt;CODE BEGINS&gt;
1406
1407 /**
1408 Copyright (c) 2011 IETF Trust and the persons identified as
1409 authors of the code. All rights reserved.
1410
1411 Redistribution and use in source and binary forms, with or without
1412 modification, is permitted pursuant to, and subject to the license
1413 terms contained in, the Simplified BSD License set forth in <a href="#section-4">Section</a>
1414 <a href="#section-4">4</a>.c of the IETF Trust's Legal Provisions Relating to IETF Documents
1415 (<a href="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</a>).
1416 */
1417
1418 import java.math.BigInteger;
1419 import java.util.*;
1420 import java.text.DateFormat;
1421 import java.text.SimpleDateFormat;
1422
1423 public class TestOCRA {
1424
1425 public static String asHex (byte buf[]) {
1426 StringBuffer strbuf = new StringBuffer(buf.length * 2);
1427 int i;
1428
1429 for (i = 0; i &lt; buf.length; i++) {
1430 if (((int) buf[i] &amp; 0xff) &lt; 0x10)
1431 strbuf.append("0");
1432 strbuf.append(Long.toString((int) buf[i] &amp; 0xff, 16));
1433 }
1434 return strbuf.toString();
1435 }
1436
1437 /**
1438 * @param args
1439 */
1440 public static void main(String[] args) {
1441
1442 String ocra = "";
1443 String seed = "";
1444 String ocraSuite = "";
1445 String counter = "";
1446 String password = "";
1447 String sessionInformation = "";
1448 String question = "";
1449
1450
1451
1452 <span class="grey">M'Raihi, et al. Informational [Page 26]</span></pre>
1453 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-27" ></span>
1454 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1455
1456
1457 String qHex = "";
1458 String timeStamp = "";
1459
1460 // PASS1234 is SHA1 hash of "1234"
1461 String PASS1234 = "7110eda4d09e062aa5e4a390b0a572ac0d2c0220";
1462
1463 String SEED = "3132333435363738393031323334353637383930";
1464 String SEED32 = "31323334353637383930313233343536373839" +
1465 "30313233343536373839303132";
1466 String SEED64 = "31323334353637383930313233343536373839" +
1467 "3031323334353637383930313233343536373839" +
1468 "3031323334353637383930313233343536373839" +
1469 "3031323334";
1470 int STOP = 5;
1471
1472 Date myDate = Calendar.getInstance().getTime();
1473 BigInteger b = new BigInteger("0");
1474 String sDate = "Mar 25 2008, 12:06:30 GMT";
1475
1476 try{
1477 DateFormat df =
1478 new SimpleDateFormat("MMM dd yyyy, HH:mm:ss zzz");
1479 myDate = df.parse(sDate);
1480 b = new BigInteger("0" + myDate.getTime());
1481 b = b.divide(new BigInteger("60000"));
1482
1483
1484 System.out.println("Time of \"" + sDate + "\" is in");
1485 System.out.println("milli sec: " + myDate.getTime());
1486 System.out.println("minutes: " + b.toString());
1487 System.out.println("minutes (HEX encoded): "
1488 + b.toString(16).toUpperCase());
1489 System.out.println("Time of \"" + sDate
1490 + "\" is the same as this localized");
1491 System.out.println("time, \""
1492 + new Date(myDate.getTime()) + "\"");
1493
1494 System.out.println();
1495 System.out.println("Standard 20Byte key: " +
1496 "3132333435363738393031323334353637383930");
1497 System.out.println("Standard 32Byte key: " +
1498 "3132333435363738393031323334353637383930");
1499 System.out.println(" " +
1500 "313233343536373839303132");
1501 System.out.println("Standard 64Byte key: 313233343536373839"
1502 + "3031323334353637383930");
1503 System.out.println(" 313233343536373839"
1504 + "3031323334353637383930");
1505
1506
1507
1508 <span class="grey">M'Raihi, et al. Informational [Page 27]</span></pre>
1509 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-28" ></span>
1510 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1511
1512
1513 System.out.println(" 313233343536373839"
1514 + "3031323334353637383930");
1515 System.out.println(" 31323334");
1516
1517 System.out.println();
1518 System.out.println("Plain challenge response");
1519 System.out.println("========================");
1520 System.out.println();
1521
1522 ocraSuite = "OCRA-1:HOTP-SHA1-6:QN08";
1523 System.out.println(ocraSuite);
1524 System.out.println("=======================");
1525 seed = SEED;
1526 counter = "";
1527 question = "";
1528 password = "";
1529 sessionInformation = "";
1530 timeStamp = "";
1531 for(int i=0; i &lt; 10; i++){
1532 question = "" + i + i + i + i + i + i + i + i;
1533 qHex = new String((new BigInteger(question,10))
1534 .toString(16)).toUpperCase();
1535 ocra = OCRA.generateOCRA(ocraSuite,seed,counter,
1536 qHex,password,
1537 sessionInformation,timeStamp);
1538 System.out.println("Key: Standard 20Byte Q: "
1539 + question + " OCRA: " + ocra);
1540 }
1541 System.out.println();
1542
1543 ocraSuite = "OCRA-1:HOTP-SHA256-8:C-QN08-PSHA1";
1544 System.out.println(ocraSuite);
1545 System.out.println("=================================");
1546 seed = SEED32;
1547 counter = "";
1548 question = "12345678";
1549 password = PASS1234;
1550 sessionInformation = "";
1551 timeStamp = "";
1552 for(int i=0; i &lt; 10; i++){
1553 counter = "" + i;
1554 qHex = new String((new BigInteger(question,10))
1555 .toString(16)).toUpperCase();
1556 ocra = OCRA.generateOCRA(ocraSuite,seed,counter,
1557 qHex,password,sessionInformation,timeStamp);
1558 System.out.println("Key: Standard 32Byte C: "
1559 + counter + " Q: "
1560 + question + " PIN(1234): ");
1561
1562
1563
1564 <span class="grey">M'Raihi, et al. Informational [Page 28]</span></pre>
1565 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-29" ></span>
1566 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1567
1568
1569 System.out.println(password + " OCRA: " + ocra);
1570 }
1571 System.out.println();
1572
1573 ocraSuite = "OCRA-1:HOTP-SHA256-8:QN08-PSHA1";
1574 System.out.println(ocraSuite);
1575 System.out.println("===============================");
1576 seed = SEED32;
1577 counter = "";
1578 question = "";
1579 password = PASS1234;
1580 sessionInformation = "";
1581 timeStamp = "";
1582 for(int i=0; i &lt; STOP; i++){
1583 question = "" + i + i + i + i + i + i + i + i;
1584
1585 qHex = new String((new BigInteger(question,10))
1586 .toString(16)).toUpperCase();
1587 ocra = OCRA.generateOCRA(ocraSuite,seed,counter,
1588 qHex,password,sessionInformation,timeStamp);
1589 System.out.println("Key: Standard 32Byte Q: "
1590 + question + " PIN(1234): ");
1591 System.out.println(password + " OCRA: " + ocra);
1592 }
1593 System.out.println();
1594
1595 ocraSuite = "OCRA-1:HOTP-SHA512-8:C-QN08";
1596 System.out.println(ocraSuite);
1597 System.out.println("===========================");
1598 seed = SEED64;
1599 counter = "";
1600 question = "";
1601 password = "";
1602 sessionInformation = "";
1603 timeStamp = "";
1604 for(int i=0; i &lt; 10; i++){
1605 question = "" + i + i + i + i + i + i + i + i;
1606 qHex = new String((new BigInteger(question,10))
1607 .toString(16)).toUpperCase();
1608 counter = "0000" + i;
1609 ocra = OCRA.generateOCRA(ocraSuite,seed,counter,
1610 qHex,password,sessionInformation,timeStamp);
1611 System.out.println("Key: Standard 64Byte C: "
1612 + counter + " Q: "
1613 + question + " OCRA: " + ocra);
1614 }
1615 System.out.println();
1616
1617
1618
1619
1620 <span class="grey">M'Raihi, et al. Informational [Page 29]</span></pre>
1621 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-30" ></span>
1622 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1623
1624
1625 ocraSuite = "OCRA-1:HOTP-SHA512-8:QN08-T1M";
1626 System.out.println(ocraSuite);
1627 System.out.println("=============================");
1628 seed = SEED64;
1629 counter = "";
1630 question = "";
1631 password = "";
1632 sessionInformation = "";
1633 timeStamp = b.toString(16);
1634 for(int i=0; i &lt; STOP; i++){
1635 question = "" + i + i + i + i + i + i + i + i;
1636 counter = "";
1637 qHex = new String((new BigInteger(question,10))
1638 .toString(16)).toUpperCase();
1639 ocra = OCRA.generateOCRA(ocraSuite,seed,counter,
1640 qHex,password,sessionInformation,timeStamp);
1641
1642 System.out.println("Key: Standard 64Byte Q: "
1643 + question +" T: "
1644 + timeStamp.toUpperCase()
1645 + " OCRA: " + ocra);
1646 }
1647 System.out.println();
1648
1649 System.out.println();
1650 System.out.println("Mutual Challenge Response");
1651 System.out.println("=========================");
1652 System.out.println();
1653
1654 ocraSuite = "OCRA-1:HOTP-SHA256-8:QA08";
1655 System.out.println("OCRASuite (server computation) = "
1656 + ocraSuite);
1657 System.out.println("OCRASuite (client computation) = "
1658 + ocraSuite);
1659 System.out.println("===============================" +
1660 "===========================");
1661 seed = SEED32;
1662 counter = "";
1663 question = "";
1664 password = "";
1665 sessionInformation = "";
1666 timeStamp = "";
1667 for(int i=0; i &lt; STOP; i++){
1668 question = "CLI2222" + i + "SRV1111" + i;
1669 qHex = asHex(question.getBytes());
1670 ocra = OCRA.generateOCRA(ocraSuite,seed,counter,qHex,
1671 password,sessionInformation,timeStamp);
1672 System.out.println(
1673
1674
1675
1676 <span class="grey">M'Raihi, et al. Informational [Page 30]</span></pre>
1677 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-31" ></span>
1678 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1679
1680
1681 "(server)Key: Standard 32Byte Q: "
1682 + question + " OCRA: "
1683 + ocra);
1684 question = "SRV1111" + i + "CLI2222" + i;
1685 qHex = asHex(question.getBytes());
1686 ocra = OCRA.generateOCRA(ocraSuite,seed,counter,qHex,
1687 password,sessionInformation,timeStamp);
1688 System.out.println(
1689 "(client)Key: Standard 32Byte Q: "
1690 + question + " OCRA: "
1691 + ocra);
1692 }
1693 System.out.println();
1694
1695 String ocraSuite1 = "OCRA-1:HOTP-SHA512-8:QA08";
1696 String ocraSuite2 = "OCRA-1:HOTP-SHA512-8:QA08-PSHA1";
1697 System.out.println("OCRASuite (server computation) = "
1698 + ocraSuite1);
1699 System.out.println("OCRASuite (client computation) = "
1700 + ocraSuite2);
1701 System.out.println("===============================" +
1702 "=================================");
1703 ocraSuite = "";
1704 seed = SEED64;
1705 counter = "";
1706 question = "";
1707 password = "";
1708 sessionInformation = "";
1709 timeStamp = "";
1710 for(int i=0; i &lt; STOP; i++){
1711 ocraSuite = ocraSuite1;
1712 question = "CLI2222" + i + "SRV1111" + i;
1713 qHex = asHex(question.getBytes());
1714 password = "";
1715 ocra = OCRA.generateOCRA(ocraSuite,seed,counter,qHex,
1716 password,sessionInformation,timeStamp);
1717 System.out.println(
1718 "(server)Key: Standard 64Byte Q: "
1719 + question + " OCRA: "
1720 + ocra);
1721 ocraSuite = ocraSuite2;
1722 question = "SRV1111" + i + "CLI2222" + i;
1723 qHex = asHex(question.getBytes());
1724 password = PASS1234;
1725 ocra = OCRA.generateOCRA(ocraSuite,seed,counter,qHex,
1726 password,sessionInformation,timeStamp);
1727 System.out.println("(client)Key: Standard 64Byte Q: "
1728 + question);
1729
1730
1731
1732 <span class="grey">M'Raihi, et al. Informational [Page 31]</span></pre>
1733 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-32" ></span>
1734 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1735
1736
1737 System.out.println("P: " + password.toUpperCase()
1738 + " OCRA: " + ocra);
1739 }
1740 System.out.println();
1741
1742 System.out.println();
1743 System.out.println("Plain Signature");
1744 System.out.println("===============");
1745 System.out.println();
1746 ocraSuite = "OCRA-1:HOTP-SHA256-8:QA08";
1747 System.out.println(ocraSuite);
1748 System.out.println("=========================");
1749 seed = SEED32;
1750 counter = "";
1751 question = "";
1752 password = "";
1753 sessionInformation = "";
1754 timeStamp = "";
1755 for(int i=0; i &lt; STOP; i++){
1756 question = "SIG1" + i + "000";
1757 qHex = asHex(question.getBytes());
1758 ocra = OCRA.generateOCRA(ocraSuite,seed,counter,qHex,
1759 password,sessionInformation,timeStamp);
1760 System.out.println(
1761 "Key: Standard 32Byte Q(Signature challenge): "
1762 + question);
1763 System.out.println(" OCRA: " + ocra);
1764 }
1765 System.out.println();
1766
1767 ocraSuite = "OCRA-1:HOTP-SHA512-8:QA10-T1M";
1768 System.out.println(ocraSuite);
1769 System.out.println("=============================");
1770 seed = SEED64;
1771 counter = "";
1772 question = "";
1773 password = "";
1774 sessionInformation = "";
1775 timeStamp = b.toString(16);
1776 for(int i=0; i &lt; STOP; i++){
1777 question = "SIG1" + i + "00000";
1778 qHex = asHex(question.getBytes());
1779 ocra = OCRA.generateOCRA(ocraSuite,seed,counter,
1780 qHex,password,sessionInformation,timeStamp);
1781 System.out.println(
1782 "Key: Standard 64Byte Q(Signature challenge): "
1783 + question);
1784 System.out.println(" T: "
1785
1786
1787
1788 <span class="grey">M'Raihi, et al. Informational [Page 32]</span></pre>
1789 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-33" ></span>
1790 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1791
1792
1793 + timeStamp.toUpperCase() + " OCRA: "
1794 + ocra);
1795 }
1796
1797 }catch (Exception e){
1798 System.out.println("Error : " + e);
1799 }
1800 }
1801 }
1802 &lt;CODE ENDS&gt;
1803
1804 <span class="h2"><a class="selflink" id="appendix-C" href="#appendix-C">Appendix C</a>. Test Vectors</span>
1805
1806 This section provides test values that can be used for the OCRA
1807 interoperability test.
1808
1809 Standard 20Byte key:
1810
1811 3132333435363738393031323334353637383930
1812
1813 Standard 32Byte key:
1814
1815 3132333435363738393031323334353637383930313233343536373839303132
1816
1817 Standard 64Byte key:
1818
1819 313233343536373839303132333435363738393031323334353637383930313233343
1820 53637383930313233343536373839303132333435363738393031323334
1821
1822 PIN (1234) SHA1 hash value:
1823
1824 7110eda4d09e062aa5e4a390b0a572ac0d2c0220
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844 <span class="grey">M'Raihi, et al. Informational [Page 33]</span></pre>
1845 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-34" ></span>
1846 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1847
1848
1849 <span class="h3"><a class="selflink" id="appendix-C.1" href="#appendix-C.1">C.1</a>. One-Way Challenge Response</span>
1850
1851 +-----------------+----------+------------+
1852 | Key | Q | OCRA Value |
1853 +-----------------+----------+------------+
1854 | Standard 20Byte | 00000000 | 237653 |
1855 | Standard 20Byte | 11111111 | 243178 |
1856 | Standard 20Byte | 22222222 | 653583 |
1857 | Standard 20Byte | 33333333 | 740991 |
1858 | Standard 20Byte | 44444444 | 608993 |
1859 | Standard 20Byte | 55555555 | 388898 |
1860 | Standard 20Byte | 66666666 | 816933 |
1861 | Standard 20Byte | 77777777 | 224598 |
1862 | Standard 20Byte | 88888888 | 750600 |
1863 | Standard 20Byte | 99999999 | 294470 |
1864 +-----------------+----------+------------+
1865
1866 OCRA-1:HOTP-SHA1-6:QN08
1867
1868 +-----------------+---+----------+------------+
1869 | Key | C | Q | OCRA Value |
1870 +-----------------+---+----------+------------+
1871 | Standard 32Byte | 0 | 12345678 | 65347737 |
1872 | Standard 32Byte | 1 | 12345678 | 86775851 |
1873 | Standard 32Byte | 2 | 12345678 | 78192410 |
1874 | Standard 32Byte | 3 | 12345678 | 71565254 |
1875 | Standard 32Byte | 4 | 12345678 | 10104329 |
1876 | Standard 32Byte | 5 | 12345678 | 65983500 |
1877 | Standard 32Byte | 6 | 12345678 | 70069104 |
1878 | Standard 32Byte | 7 | 12345678 | 91771096 |
1879 | Standard 32Byte | 8 | 12345678 | 75011558 |
1880 | Standard 32Byte | 9 | 12345678 | 08522129 |
1881 +-----------------+---+----------+------------+
1882
1883 OCRA-1:HOTP-SHA256-8:C-QN08-PSHA1
1884
1885 +-----------------+----------+------------+
1886 | Key | Q | OCRA Value |
1887 +-----------------+----------+------------+
1888 | Standard 32Byte | 00000000 | 83238735 |
1889 | Standard 32Byte | 11111111 | 01501458 |
1890 | Standard 32Byte | 22222222 | 17957585 |
1891 | Standard 32Byte | 33333333 | 86776967 |
1892 | Standard 32Byte | 44444444 | 86807031 |
1893 +-----------------+----------+------------+
1894
1895 OCRA-1:HOTP-SHA256-8:QN08-PSHA1
1896
1897
1898
1899
1900 <span class="grey">M'Raihi, et al. Informational [Page 34]</span></pre>
1901 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-35" ></span>
1902 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1903
1904
1905 +-----------------+-------+----------+------------+
1906 | Key | C | Q | OCRA Value |
1907 +-----------------+-------+----------+------------+
1908 | Standard 64Byte | 00000 | 00000000 | 07016083 |
1909 | Standard 64Byte | 00001 | 11111111 | 63947962 |
1910 | Standard 64Byte | 00002 | 22222222 | 70123924 |
1911 | Standard 64Byte | 00003 | 33333333 | 25341727 |
1912 | Standard 64Byte | 00004 | 44444444 | 33203315 |
1913 | Standard 64Byte | 00005 | 55555555 | 34205738 |
1914 | Standard 64Byte | 00006 | 66666666 | 44343969 |
1915 | Standard 64Byte | 00007 | 77777777 | 51946085 |
1916 | Standard 64Byte | 00008 | 88888888 | 20403879 |
1917 | Standard 64Byte | 00009 | 99999999 | 31409299 |
1918 +-----------------+-------+----------+------------+
1919
1920 OCRA-1:HOTP-SHA512-8:C-QN08
1921
1922 +-----------------+----------+---------+------------+
1923 | Key | Q | T | OCRA Value |
1924 +-----------------+----------+---------+------------+
1925 | Standard 64Byte | 00000000 | 132d0b6 | 95209754 |
1926 | Standard 64Byte | 11111111 | 132d0b6 | 55907591 |
1927 | Standard 64Byte | 22222222 | 132d0b6 | 22048402 |
1928 | Standard 64Byte | 33333333 | 132d0b6 | 24218844 |
1929 | Standard 64Byte | 44444444 | 132d0b6 | 36209546 |
1930 +-----------------+----------+---------+------------+
1931
1932 OCRA-1:HOTP-SHA512-8:QN08-T1M
1933
1934 <span class="h3"><a class="selflink" id="appendix-C.2" href="#appendix-C.2">C.2</a>. Mutual Challenge-Response</span>
1935
1936 OCRASuite (server computation) = OCRA-1:HOTP-SHA256-8:QA08
1937
1938 OCRASuite (client computation) = OCRA-1:HOTP-SHA256-8:QA08
1939
1940 +-----------------+------------------+------------+
1941 | Key | Q | OCRA Value |
1942 +-----------------+------------------+------------+
1943 | Standard 32Byte | CLI22220SRV11110 | 28247970 |
1944 | Standard 32Byte | CLI22221SRV11111 | 01984843 |
1945 | Standard 32Byte | CLI22222SRV11112 | 65387857 |
1946 | Standard 32Byte | CLI22223SRV11113 | 03351211 |
1947 | Standard 32Byte | CLI22224SRV11114 | 83412541 |
1948 +-----------------+------------------+------------+
1949
1950 Server -- OCRA-1:HOTP-SHA256-8:QA08
1951
1952
1953
1954
1955
1956 <span class="grey">M'Raihi, et al. Informational [Page 35]</span></pre>
1957 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-36" ></span>
1958 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
1959
1960
1961 +-----------------+------------------+------------+
1962 | Key | Q | OCRA Value |
1963 +-----------------+------------------+------------+
1964 | Standard 32Byte | SRV11110CLI22220 | 15510767 |
1965 | Standard 32Byte | SRV11111CLI22221 | 90175646 |
1966 | Standard 32Byte | SRV11112CLI22222 | 33777207 |
1967 | Standard 32Byte | SRV11113CLI22223 | 95285278 |
1968 | Standard 32Byte | SRV11114CLI22224 | 28934924 |
1969 +-----------------+------------------+------------+
1970
1971 Client -- OCRA-1:HOTP-SHA256-8:QA08
1972
1973 OCRASuite (server computation) = OCRA-1:HOTP-SHA512-8:QA08
1974
1975 OCRASuite (client computation) = OCRA-1:HOTP-SHA512-8:QA08-PSHA1
1976
1977 +-----------------+------------------+------------+
1978 | Key | Q | OCRA Value |
1979 +-----------------+------------------+------------+
1980 | Standard 64Byte | CLI22220SRV11110 | 79496648 |
1981 | Standard 64Byte | CLI22221SRV11111 | 76831980 |
1982 | Standard 64Byte | CLI22222SRV11112 | 12250499 |
1983 | Standard 64Byte | CLI22223SRV11113 | 90856481 |
1984 | Standard 64Byte | CLI22224SRV11114 | 12761449 |
1985 +-----------------+------------------+------------+
1986
1987 Server -- OCRA-1:HOTP-SHA512-8:QA08
1988
1989 +-----------------+------------------+------------+
1990 | Key | Q | OCRA Value |
1991 +-----------------+------------------+------------+
1992 | Standard 64Byte | SRV11110CLI22220 | 18806276 |
1993 | Standard 64Byte | SRV11111CLI22221 | 70020315 |
1994 | Standard 64Byte | SRV11112CLI22222 | 01600026 |
1995 | Standard 64Byte | SRV11113CLI22223 | 18951020 |
1996 | Standard 64Byte | SRV11114CLI22224 | 32528969 |
1997 +-----------------+------------------+------------+
1998
1999 Client -- OCRA-1:HOTP-SHA512-8:QA08-PSHA1
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012 <span class="grey">M'Raihi, et al. Informational [Page 36]</span></pre>
2013 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-37" ></span>
2014 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
2015
2016
2017 <span class="h3"><a class="selflink" id="appendix-C.3" href="#appendix-C.3">C.3</a>. Plain Signature</span>
2018
2019 In this mode of operation, Q represents the signature challenge.
2020
2021 +-----------------+----------+------------+
2022 | Key | Q | OCRA Value |
2023 +-----------------+----------+------------+
2024 | Standard 32Byte | SIG10000 | 53095496 |
2025 | Standard 32Byte | SIG11000 | 04110475 |
2026 | Standard 32Byte | SIG12000 | 31331128 |
2027 | Standard 32Byte | SIG13000 | 76028668 |
2028 | Standard 32Byte | SIG14000 | 46554205 |
2029 +-----------------+----------+------------+
2030
2031 OCRA-1:HOTP-SHA256-8:QA08
2032
2033 +-----------------+------------+---------+------------+
2034 | Key | Q | T | OCRA Value |
2035 +-----------------+------------+---------+------------+
2036 | Standard 64Byte | SIG1000000 | 132d0b6 | 77537423 |
2037 | Standard 64Byte | SIG1100000 | 132d0b6 | 31970405 |
2038 | Standard 64Byte | SIG1200000 | 132d0b6 | 10235557 |
2039 | Standard 64Byte | SIG1300000 | 132d0b6 | 95213541 |
2040 | Standard 64Byte | SIG1400000 | 132d0b6 | 65360607 |
2041 +-----------------+------------+---------+------------+
2042
2043 OCRA-1:HOTP-SHA512-8:QA10-T1M
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068 <span class="grey">M'Raihi, et al. Informational [Page 37]</span></pre>
2069 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-38" ></span>
2070 <span class="grey"><a href="./rfc6287">RFC 6287</a> OCRA June 2011</span>
2071
2072
2073 Authors' Addresses
2074
2075 David M'Raihi
2076 Verisign, Inc.
2077 487 E. Middlefield Road
2078 Mountain View, CA 94043
2079 USA
2080
2081 EMail: [email protected]
2082
2083
2084 Johan Rydell
2085 Portwise, Inc.
2086 275 Hawthorne Ave, Suite 119
2087 Palo Alto, CA 94301
2088 USA
2089
2090 EMail: [email protected]
2091
2092
2093 Siddharth Bajaj
2094 Symantec Corp.
2095 350 Ellis Street
2096 Mountain View, CA 94043
2097 USA
2098
2099 EMail: [email protected]
2100
2101
2102 Salah Machani
2103 Diversinet Corp.
2104 2225 Sheppard Avenue East, Suite 1801
2105 Toronto, Ontario M2J 5C2
2106 Canada
2107
2108 EMail: [email protected]
2109
2110
2111 David Naccache
2112 Ecole Normale Superieure
2113 ENS DI, 45 rue d'Ulm
2114 Paris, 75005
2115 France
2116
2117 EMail: [email protected]
2118
2119
2120
2121
2122
2123
2124 M'Raihi, et al. Informational [Page 38]
2125 </pre>