···11+/* sha1.c - Functions to compute SHA1 message digest of files or
22+ memory blocks according to the NIST specification FIPS-180-1.
33+44+ Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006 Free Software
55+ Foundation, Inc.
66+77+ This program is free software; you can redistribute it and/or modify it
88+ under the terms of the GNU General Public License as published by the
99+ Free Software Foundation; either version 2, or (at your option) any
1010+ later version.
1111+1212+ This program is distributed in the hope that it will be useful,
1313+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1414+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515+ GNU General Public License for more details.
1616+1717+ You should have received a copy of the GNU General Public License
1818+ along with this program; if not, write to the Free Software Foundation,
1919+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
2020+2121+/* Written by Scott G. Miller
2222+ Credits:
2323+ Robert Klep <robert@ilse.nl> -- Expansion function fix
2424+*/
2525+2626+#include "plugin.h"
2727+#include "sha1.h"
2828+2929+#ifdef WORDS_BIGENDIAN
3030+# define SWAP(n) (n)
3131+#else
3232+# define SWAP(n) \
3333+ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
3434+#endif
3535+3636+#define BLOCKSIZE 4096
3737+#if BLOCKSIZE % 64 != 0
3838+# error "invalid BLOCKSIZE"
3939+#endif
4040+4141+/* This array contains the bytes used to pad the buffer to the next
4242+ 64-byte boundary. (RFC 1321, 3.1: Step 1) */
4343+static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
4444+4545+4646+/* Take a pointer to a 160 bit block of data (five 32 bit ints) and
4747+ initialize it to the start constants of the SHA1 algorithm. This
4848+ must be called before using hash in the call to sha1_hash. */
4949+void
5050+sha1_init_ctx (struct sha1_ctx *ctx)
5151+{
5252+ ctx->A = 0x67452301;
5353+ ctx->B = 0xefcdab89;
5454+ ctx->C = 0x98badcfe;
5555+ ctx->D = 0x10325476;
5656+ ctx->E = 0xc3d2e1f0;
5757+5858+ ctx->total[0] = ctx->total[1] = 0;
5959+ ctx->buflen = 0;
6060+}
6161+6262+/* Put result from CTX in first 20 bytes following RESBUF. The result
6363+ must be in little endian byte order.
6464+6565+ IMPORTANT: On some systems it is required that RESBUF is correctly
6666+ aligned for a 32-bit value. */
6767+void *
6868+sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
6969+{
7070+ ((uint32_t *) resbuf)[0] = SWAP (ctx->A);
7171+ ((uint32_t *) resbuf)[1] = SWAP (ctx->B);
7272+ ((uint32_t *) resbuf)[2] = SWAP (ctx->C);
7373+ ((uint32_t *) resbuf)[3] = SWAP (ctx->D);
7474+ ((uint32_t *) resbuf)[4] = SWAP (ctx->E);
7575+7676+ return resbuf;
7777+}
7878+7979+/* Process the remaining bytes in the internal buffer and the usual
8080+ prolog according to the standard and write the result to RESBUF.
8181+8282+ IMPORTANT: On some systems it is required that RESBUF is correctly
8383+ aligned for a 32-bit value. */
8484+void *
8585+sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
8686+{
8787+ /* Take yet unprocessed bytes into account. */
8888+ uint32_t bytes = ctx->buflen;
8989+ size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
9090+9191+ /* Now count remaining bytes. */
9292+ ctx->total[0] += bytes;
9393+ if (ctx->total[0] < bytes)
9494+ ++ctx->total[1];
9595+9696+ /* Put the 64-bit file length in *bits* at the end of the buffer. */
9797+ ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
9898+ ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
9999+100100+ memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
101101+102102+ /* Process last bytes. */
103103+ sha1_process_block (ctx->buffer, size * 4, ctx);
104104+105105+ return sha1_read_ctx (ctx, resbuf);
106106+}
107107+108108+/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
109109+ result is always in little endian byte order, so that a byte-wise
110110+ output yields to the wanted ASCII representation of the message
111111+ digest. */
112112+void *sha1_buffer (const char *buffer, size_t len, void *resblock)
113113+{
114114+ struct sha1_ctx ctx;
115115+116116+ /* Initialize the computation context. */
117117+ sha1_init_ctx (&ctx);
118118+119119+ /* Process whole buffer but last len % 64 bytes. */
120120+ sha1_process_bytes (buffer, len, &ctx);
121121+122122+ /* Put result in desired memory area. */
123123+ return sha1_finish_ctx (&ctx, resblock);
124124+}
125125+126126+void
127127+sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
128128+{
129129+ /* When we already have some bits in our internal buffer concatenate
130130+ both inputs first. */
131131+ if (ctx->buflen != 0)
132132+ {
133133+ size_t left_over = ctx->buflen;
134134+ size_t add = 128 - left_over > len ? len : 128 - left_over;
135135+136136+ memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
137137+ ctx->buflen += add;
138138+139139+ if (ctx->buflen > 64)
140140+ {
141141+ sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
142142+143143+ ctx->buflen &= 63;
144144+ /* The regions in the following copy operation cannot overlap. */
145145+ memcpy (ctx->buffer,
146146+ &((char *) ctx->buffer)[(left_over + add) & ~63],
147147+ ctx->buflen);
148148+ }
149149+150150+ buffer = (const char *) buffer + add;
151151+ len -= add;
152152+ }
153153+154154+ /* Process available complete blocks. */
155155+ if (len >= 64)
156156+ {
157157+ {
158158+ sha1_process_block (buffer, len & ~63, ctx);
159159+ buffer = (const char *) buffer + (len & ~63);
160160+ len &= 63;
161161+ }
162162+ }
163163+164164+ /* Move remaining bytes in internal buffer. */
165165+ if (len > 0)
166166+ {
167167+ size_t left_over = ctx->buflen;
168168+169169+ memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
170170+ left_over += len;
171171+ if (left_over >= 64)
172172+ {
173173+ sha1_process_block (ctx->buffer, 64, ctx);
174174+ left_over -= 64;
175175+ memcpy (ctx->buffer, &ctx->buffer[16], left_over);
176176+ }
177177+ ctx->buflen = left_over;
178178+ }
179179+}
180180+181181+/* --- Code below is the primary difference between md5.c and sha1.c --- */
182182+183183+/* SHA1 round constants */
184184+#define K1 0x5a827999
185185+#define K2 0x6ed9eba1
186186+#define K3 0x8f1bbcdc
187187+#define K4 0xca62c1d6
188188+189189+/* Round functions. Note that F2 is the same as F4. */
190190+#define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) )
191191+#define F2(B,C,D) (B ^ C ^ D)
192192+#define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) )
193193+#define F4(B,C,D) (B ^ C ^ D)
194194+195195+/* Process LEN bytes of BUFFER, accumulating context into CTX.
196196+ It is assumed that LEN % 64 == 0.
197197+ Most of this code comes from GnuPG's cipher/sha1.c. */
198198+199199+void
200200+sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
201201+{
202202+ const uint32_t *words = buffer;
203203+ size_t nwords = len / sizeof (uint32_t);
204204+ const uint32_t *endp = words + nwords;
205205+ uint32_t x[16];
206206+ uint32_t a = ctx->A;
207207+ uint32_t b = ctx->B;
208208+ uint32_t c = ctx->C;
209209+ uint32_t d = ctx->D;
210210+ uint32_t e = ctx->E;
211211+212212+ /* First increment the byte count. RFC 1321 specifies the possible
213213+ length of the file up to 2^64 bits. Here we only compute the
214214+ number of bytes. Do a double word increment. */
215215+ ctx->total[0] += len;
216216+ if (ctx->total[0] < len)
217217+ ++ctx->total[1];
218218+219219+#define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n))))
220220+221221+#define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \
222222+ ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
223223+ , (x[I&0x0f] = rol(tm, 1)) )
224224+225225+#define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \
226226+ + F( B, C, D ) \
227227+ + K \
228228+ + M; \
229229+ B = rol( B, 30 ); \
230230+ } while(0)
231231+232232+ while (words < endp)
233233+ {
234234+ uint32_t tm;
235235+ int t;
236236+ for (t = 0; t < 16; t++)
237237+ {
238238+ x[t] = SWAP (*words);
239239+ words++;
240240+ }
241241+242242+ R( a, b, c, d, e, F1, K1, x[ 0] );
243243+ R( e, a, b, c, d, F1, K1, x[ 1] );
244244+ R( d, e, a, b, c, F1, K1, x[ 2] );
245245+ R( c, d, e, a, b, F1, K1, x[ 3] );
246246+ R( b, c, d, e, a, F1, K1, x[ 4] );
247247+ R( a, b, c, d, e, F1, K1, x[ 5] );
248248+ R( e, a, b, c, d, F1, K1, x[ 6] );
249249+ R( d, e, a, b, c, F1, K1, x[ 7] );
250250+ R( c, d, e, a, b, F1, K1, x[ 8] );
251251+ R( b, c, d, e, a, F1, K1, x[ 9] );
252252+ R( a, b, c, d, e, F1, K1, x[10] );
253253+ R( e, a, b, c, d, F1, K1, x[11] );
254254+ R( d, e, a, b, c, F1, K1, x[12] );
255255+ R( c, d, e, a, b, F1, K1, x[13] );
256256+ R( b, c, d, e, a, F1, K1, x[14] );
257257+ R( a, b, c, d, e, F1, K1, x[15] );
258258+ R( e, a, b, c, d, F1, K1, M(16) );
259259+ R( d, e, a, b, c, F1, K1, M(17) );
260260+ R( c, d, e, a, b, F1, K1, M(18) );
261261+ R( b, c, d, e, a, F1, K1, M(19) );
262262+ R( a, b, c, d, e, F2, K2, M(20) );
263263+ R( e, a, b, c, d, F2, K2, M(21) );
264264+ R( d, e, a, b, c, F2, K2, M(22) );
265265+ R( c, d, e, a, b, F2, K2, M(23) );
266266+ R( b, c, d, e, a, F2, K2, M(24) );
267267+ R( a, b, c, d, e, F2, K2, M(25) );
268268+ R( e, a, b, c, d, F2, K2, M(26) );
269269+ R( d, e, a, b, c, F2, K2, M(27) );
270270+ R( c, d, e, a, b, F2, K2, M(28) );
271271+ R( b, c, d, e, a, F2, K2, M(29) );
272272+ R( a, b, c, d, e, F2, K2, M(30) );
273273+ R( e, a, b, c, d, F2, K2, M(31) );
274274+ R( d, e, a, b, c, F2, K2, M(32) );
275275+ R( c, d, e, a, b, F2, K2, M(33) );
276276+ R( b, c, d, e, a, F2, K2, M(34) );
277277+ R( a, b, c, d, e, F2, K2, M(35) );
278278+ R( e, a, b, c, d, F2, K2, M(36) );
279279+ R( d, e, a, b, c, F2, K2, M(37) );
280280+ R( c, d, e, a, b, F2, K2, M(38) );
281281+ R( b, c, d, e, a, F2, K2, M(39) );
282282+ R( a, b, c, d, e, F3, K3, M(40) );
283283+ R( e, a, b, c, d, F3, K3, M(41) );
284284+ R( d, e, a, b, c, F3, K3, M(42) );
285285+ R( c, d, e, a, b, F3, K3, M(43) );
286286+ R( b, c, d, e, a, F3, K3, M(44) );
287287+ R( a, b, c, d, e, F3, K3, M(45) );
288288+ R( e, a, b, c, d, F3, K3, M(46) );
289289+ R( d, e, a, b, c, F3, K3, M(47) );
290290+ R( c, d, e, a, b, F3, K3, M(48) );
291291+ R( b, c, d, e, a, F3, K3, M(49) );
292292+ R( a, b, c, d, e, F3, K3, M(50) );
293293+ R( e, a, b, c, d, F3, K3, M(51) );
294294+ R( d, e, a, b, c, F3, K3, M(52) );
295295+ R( c, d, e, a, b, F3, K3, M(53) );
296296+ R( b, c, d, e, a, F3, K3, M(54) );
297297+ R( a, b, c, d, e, F3, K3, M(55) );
298298+ R( e, a, b, c, d, F3, K3, M(56) );
299299+ R( d, e, a, b, c, F3, K3, M(57) );
300300+ R( c, d, e, a, b, F3, K3, M(58) );
301301+ R( b, c, d, e, a, F3, K3, M(59) );
302302+ R( a, b, c, d, e, F4, K4, M(60) );
303303+ R( e, a, b, c, d, F4, K4, M(61) );
304304+ R( d, e, a, b, c, F4, K4, M(62) );
305305+ R( c, d, e, a, b, F4, K4, M(63) );
306306+ R( b, c, d, e, a, F4, K4, M(64) );
307307+ R( a, b, c, d, e, F4, K4, M(65) );
308308+ R( e, a, b, c, d, F4, K4, M(66) );
309309+ R( d, e, a, b, c, F4, K4, M(67) );
310310+ R( c, d, e, a, b, F4, K4, M(68) );
311311+ R( b, c, d, e, a, F4, K4, M(69) );
312312+ R( a, b, c, d, e, F4, K4, M(70) );
313313+ R( e, a, b, c, d, F4, K4, M(71) );
314314+ R( d, e, a, b, c, F4, K4, M(72) );
315315+ R( c, d, e, a, b, F4, K4, M(73) );
316316+ R( b, c, d, e, a, F4, K4, M(74) );
317317+ R( a, b, c, d, e, F4, K4, M(75) );
318318+ R( e, a, b, c, d, F4, K4, M(76) );
319319+ R( d, e, a, b, c, F4, K4, M(77) );
320320+ R( c, d, e, a, b, F4, K4, M(78) );
321321+ R( b, c, d, e, a, F4, K4, M(79) );
322322+323323+ a = ctx->A += a;
324324+ b = ctx->B += b;
325325+ c = ctx->C += c;
326326+ d = ctx->D += d;
327327+ e = ctx->E += e;
328328+ }
329329+}
330330+331331+/* memxor.c -- perform binary exclusive OR operation of two memory blocks.
332332+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
333333+334334+ This program is free software; you can redistribute it and/or modify
335335+ it under the terms of the GNU General Public License as published by
336336+ the Free Software Foundation; either version 2, or (at your option)
337337+ any later version.
338338+339339+ This program is distributed in the hope that it will be useful,
340340+ but WITHOUT ANY WARRANTY; without even the implied warranty of
341341+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
342342+ GNU General Public License for more details.
343343+344344+ You should have received a copy of the GNU General Public License
345345+ along with this program; if not, write to the Free Software Foundation,
346346+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
347347+348348+/* Written by Simon Josefsson. The interface was inspired by memxor
349349+ in Niels Möller's Nettle. */
350350+351351+void *
352352+memxor (void * dest, const void * src, size_t n)
353353+{
354354+ char const *s = src;
355355+ char *d = dest;
356356+357357+ for (; n > 0; n--)
358358+ *d++ ^= *s++;
359359+360360+ return dest;
361361+}
362362+363363+/* hmac-sha1.c -- hashed message authentication codes
364364+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
365365+366366+ This program is free software; you can redistribute it and/or modify
367367+ it under the terms of the GNU General Public License as published by
368368+ the Free Software Foundation; either version 2, or (at your option)
369369+ any later version.
370370+371371+ This program is distributed in the hope that it will be useful,
372372+ but WITHOUT ANY WARRANTY; without even the implied warranty of
373373+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
374374+ GNU General Public License for more details.
375375+376376+ You should have received a copy of the GNU General Public License
377377+ along with this program; if not, write to the Free Software Foundation,
378378+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
379379+380380+/* Written by Simon Josefsson. */
381381+382382+#define IPAD 0x36
383383+#define OPAD 0x5c
384384+385385+int
386386+hmac_sha1 (const void *key, size_t keylen,
387387+ const void *in, size_t inlen, void *resbuf)
388388+{
389389+ struct sha1_ctx inner;
390390+ struct sha1_ctx outer;
391391+ char optkeybuf[20];
392392+ char block[64];
393393+ char innerhash[20];
394394+395395+ /* Reduce the key's size, so that it becomes <= 64 bytes large. */
396396+397397+ if (keylen > 64)
398398+ {
399399+ struct sha1_ctx keyhash;
400400+401401+ sha1_init_ctx (&keyhash);
402402+ sha1_process_bytes (key, keylen, &keyhash);
403403+ sha1_finish_ctx (&keyhash, optkeybuf);
404404+405405+ key = optkeybuf;
406406+ keylen = 20;
407407+ }
408408+409409+ /* Compute INNERHASH from KEY and IN. */
410410+411411+ sha1_init_ctx (&inner);
412412+413413+ memset (block, IPAD, sizeof (block));
414414+ memxor (block, key, keylen);
415415+416416+ sha1_process_block (block, 64, &inner);
417417+ sha1_process_bytes (in, inlen, &inner);
418418+419419+ sha1_finish_ctx (&inner, innerhash);
420420+421421+ /* Compute result from KEY and INNERHASH. */
422422+423423+ sha1_init_ctx (&outer);
424424+425425+ memset (block, OPAD, sizeof (block));
426426+ memxor (block, key, keylen);
427427+428428+ sha1_process_block (block, 64, &outer);
429429+ sha1_process_bytes (innerhash, 20, &outer);
430430+431431+ sha1_finish_ctx (&outer, resbuf);
432432+433433+ return 0;
434434+}
+116
apps/plugins/lib/sha1.h
···11+/* Taken from gnulib (http://savannah.gnu.org/projects/gnulib/) */
22+/* Declarations of functions and data types used for SHA1 sum
33+ library functions.
44+ Copyright (C) 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
55+66+ This program is free software; you can redistribute it and/or modify it
77+ under the terms of the GNU General Public License as published by the
88+ Free Software Foundation; either version 2, or (at your option) any
99+ later version.
1010+1111+ This program is distributed in the hope that it will be useful,
1212+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+ GNU General Public License for more details.
1515+1616+ You should have received a copy of the GNU General Public License
1717+ along with this program; if not, write to the Free Software Foundation,
1818+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
1919+2020+#ifndef SHA1_H
2121+#define SHA1_H 1
2222+2323+#include "plugin.h"
2424+2525+/* Structure to save state of computation between the single steps. */
2626+struct sha1_ctx
2727+{
2828+ uint32_t A;
2929+ uint32_t B;
3030+ uint32_t C;
3131+ uint32_t D;
3232+ uint32_t E;
3333+3434+ uint32_t total[2];
3535+ uint32_t buflen;
3636+ uint32_t buffer[32];
3737+};
3838+3939+4040+/* Initialize structure containing state of computation. */
4141+void sha1_init_ctx (struct sha1_ctx *ctx);
4242+4343+/* Starting with the result of former calls of this function (or the
4444+ initialization function update the context for the next LEN bytes
4545+ starting at BUFFER.
4646+ It is necessary that LEN is a multiple of 64!!! */
4747+void sha1_process_block (const void *buffer, size_t len,
4848+ struct sha1_ctx *ctx);
4949+5050+/* Starting with the result of former calls of this function (or the
5151+ initialization function update the context for the next LEN bytes
5252+ starting at BUFFER.
5353+ It is NOT required that LEN is a multiple of 64. */
5454+void sha1_process_bytes (const void *buffer, size_t len,
5555+ struct sha1_ctx *ctx);
5656+5757+/* Process the remaining bytes in the buffer and put result from CTX
5858+ in first 20 bytes following RESBUF. The result is always in little
5959+ endian byte order, so that a byte-wise output yields to the wanted
6060+ ASCII representation of the message digest.
6161+6262+ IMPORTANT: On some systems it is required that RESBUF be correctly
6363+ aligned for a 32 bits value. */
6464+void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
6565+6666+6767+/* Put result from CTX in first 20 bytes following RESBUF. The result is
6868+ always in little endian byte order, so that a byte-wise output yields
6969+ to the wanted ASCII representation of the message digest.
7070+7171+ IMPORTANT: On some systems it is required that RESBUF is correctly
7272+ aligned for a 32 bits value. */
7373+void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
7474+7575+/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
7676+ result is always in little endian byte order, so that a byte-wise
7777+ output yields to the wanted ASCII representation of the message
7878+ digest. */
7979+void *sha1_buffer (const char *buffer, size_t len, void *resblock);
8080+8181+#endif
8282+8383+8484+/* hmac.h -- hashed message authentication codes
8585+ Copyright (C) 2005 Free Software Foundation, Inc.
8686+8787+ This program is free software; you can redistribute it and/or modify
8888+ it under the terms of the GNU General Public License as published by
8989+ the Free Software Foundation; either version 2, or (at your option)
9090+ any later version.
9191+9292+ This program is distributed in the hope that it will be useful,
9393+ but WITHOUT ANY WARRANTY; without even the implied warranty of
9494+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9595+ GNU General Public License for more details.
9696+9797+ You should have received a copy of the GNU General Public License
9898+ along with this program; if not, write to the Free Software Foundation,
9999+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
100100+101101+/* Written by Simon Josefsson. */
102102+103103+#ifndef HMAC_H
104104+#define HMAC_H 1
105105+106106+#include <stddef.h>
107107+108108+/* Compute Hashed Message Authentication Code with SHA-1, over BUFFER
109109+ data of BUFLEN bytes using the KEY of KEYLEN bytes, writing the
110110+ output to pre-allocated 20 byte minimum RESBUF buffer. Return 0 on
111111+ success. */
112112+int
113113+hmac_sha1 (const void *key, size_t keylen,
114114+ const void *in, size_t inlen, void *resbuf);
115115+116116+#endif /* HMAC_H */
···11% $Id:$ %
2233+\label{ref:Timeanddateactual}
44+35Time related menu options. Pressing \ActionStdContext{} will voice the current time
46if voice support is enabled.
57
···11+% $Id$ %
22+\subsection{One-Time Password Client}
33+This plugin provides the ability to generate one-time passwords (OTPs)
44+for authentication purposes. It implements an HMAC-based One-Time
55+Password Algorithm (RFC 4226), and on targets which support it, a
66+Time-based One-Time Password Algorithm (RFC 6238).
77+88+\subsubsection{Adding Accounts}
99+The plugin supports two methods of adding accounts: URI import, and
1010+manual entry.
1111+1212+\opt{rtc}{ It is important to note that for TOTP (time-based) accounts
1313+ to work properly, the clock on your device MUST be accurate to no
1414+ less than 30 seconds from the time on the authentication server, and
1515+ the correct time zone must be configured in the plugin. See
1616+ \reference{ref:Timeanddateactual} for more information. }
1717+1818+\subsubsection{URI Import}
1919+This method of adding an account reads a list of URIs from a file. It
2020+expects each URI to be on a line by itself in the following format:
2121+2222+\begin{verbatim}
2323+otpauth://[hotp OR totp]/[account name]?secret=[Base32 secret][&counter=X][&period=X][&digits=X]
2424+\end{verbatim}
2525+2626+An example is shown below, provisioning a TOTP key for an account called ``bob'':
2727+2828+\begin{verbatim}
2929+otpauth://totp/bob?secret=JBSWY3DPEHPK3PXP
3030+\end{verbatim}
3131+3232+Any other URI options are not supported and will be ignored.
3333+3434+Most services will provide a scannable QR code that encodes a OTP
3535+URI. In order to use those, first scan the QR code separately and save
3636+the URI to a file on your device. If necessary, rewrite the URI so it
3737+is in the format shown above. For example, GitHub's URI has a slash
3838+after the provider. In order for this URI to be properly parsed, you
3939+must rewrite the account name so that it does not contain a slash.
4040+4141+\subsubsection{Manual Import}
4242+If direct URI import is not possible, the plugin supports the manual
4343+entry of data associated with an account. After you select the
4444+``Manual Entry'' option, it will prompt you for an account name. You
4545+may type anything you wish, but it should be memorable. It will then
4646+prompt you for the Base32-encoded secret. Most services will provide
4747+this to you directly, but some may only provide you with a QR code. In
4848+these cases, you must scan the QR code separately, and then enter the
4949+string following the ``secret='' parameter on your Rockbox device
5050+manually.
5151+5252+On devices with a real-time clock, \opt{rtc}{like yours,} the plugin
5353+will ask whether the account is a time-based account
5454+(TOTP). \opt{rtc}{If you answer ``yes'' to this question, it will ask
5555+ for further information regarding the account. Usually it is safe to
5656+ accept the defaults here. } However, if your device lacks a
5757+real-time clock, the plugin's functionality will be restricted to
5858+HMAC-based (HOTP) accounts only. If this is the case, the plugin will
5959+prompt you for information regarding the HOTP setup.
6060+6161+\opt{rtc} {
6262+ \subsection{Advanced Settings}
6363+ \subsubsection{Time Zone Configuration}
6464+ In order for TOTP accounts to work properly, the plugin must be able
6565+ to determine the current UTC time. This means that, first, your
6666+ device's clock must be synchronized with UTC time, and second, that
6767+ the plugin knows what time zone the clock is using. The plugin will
6868+ prompt you on its first run for this piece of information. However,
6969+ should this setting need changing at a later time, possibly due to
7070+ Daylight Saving Time adjustment, it is located under the
7171+ ``Advanced'' submenu. NOTE: in the UI simulator, use the ``UTC''
7272+ setting no matter what the clock may read. }