Skip to content

Commit

Permalink
Merge tag '1.3.0' into develop
Browse files Browse the repository at this point in the history
* Minor enhancements
* Add support for SHA384 and SHA512 algorithm (available: SHA1, SHA256, SHA384 and SHA512)
  • Loading branch information
BrunoMiguens committed Aug 6, 2019
2 parents fdc3ff9 + 9ffb389 commit 4b35560
Show file tree
Hide file tree
Showing 60 changed files with 2,304 additions and 70 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -36,3 +36,8 @@
* Account
* Counter
* Algorithm

## [1.3.0]

* Minor enhancements
* Add support for SHA384 and SHA512 algorithm (available: SHA1, SHA256, SHA384 and SHA512)
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -10,9 +10,10 @@ The package was implement based on [RFC4226](https://tools.ietf.org/html/rfc4226

## Feature

* Generate a `otpauth url` with the b32 encoded string
* Create and verify a HOTP object
* Create and verify a TOTP object
* Generate a `otpauth url` with the b32 encoded string
* Support for OTP tokens encrypted with SHA1, SHA256, SHA384 and SHA512

### Installation

Expand All @@ -22,7 +23,7 @@ Add `dart_otp` as a dependency in your `pubspec.yaml` file.

```yaml
dependencies:
dart_otp: ^1.2.0
dart_otp: ^1.3.0
```

### Example
Expand Down
2 changes: 1 addition & 1 deletion doc/api/__404error.html
Expand Up @@ -73,7 +73,7 @@ <h1>404: Something's gone wrong :-(</h1>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
13 changes: 8 additions & 5 deletions doc/api/dart_otp/HOTP-class.html
Expand Up @@ -59,6 +59,9 @@ <h5>dart_otp library</h5>



<li class="section-title"><a href="dart_otp/dart_otp-library.html#enums">Enums</a></li>
<li><a href="dart_otp/OTPAlgorithm-class.html">OTPAlgorithm</a></li>
<li><a href="dart_otp/OTPType-class.html">OTPType</a></li>


</ol>
Expand All @@ -77,7 +80,7 @@ <h2>Constructors</h2>

<dl class="constructor-summary-list">
<dt id="HOTP" class="callable">
<span class="name"><a href="dart_otp/HOTP/HOTP.html">HOTP</a></span><span class="signature">({<span class="parameter" id="-param-secret"><span class="type-annotation">String</span> <span class="parameter-name">secret</span>, </span> <span class="parameter" id="-param-counter"><span class="type-annotation">int</span> <span class="parameter-name">counter</span>: <span class="default-value">0</span>, </span> <span class="parameter" id="-param-digits"><span class="type-annotation">int</span> <span class="parameter-name">digits</span>: <span class="default-value">6</span>, </span> <span class="parameter" id="-param-algorithm"><span class="type-annotation">OTPAlgorithm</span> <span class="parameter-name">algorithm</span>: <span class="default-value">OTPAlgorithm.SHA1</span></span> })</span>
<span class="name"><a href="dart_otp/HOTP/HOTP.html">HOTP</a></span><span class="signature">({<span class="parameter" id="-param-secret"><span class="type-annotation">String</span> <span class="parameter-name">secret</span>, </span> <span class="parameter" id="-param-counter"><span class="type-annotation">int</span> <span class="parameter-name">counter</span>: <span class="default-value">0</span>, </span> <span class="parameter" id="-param-digits"><span class="type-annotation">int</span> <span class="parameter-name">digits</span>: <span class="default-value">6</span>, </span> <span class="parameter" id="-param-algorithm"><span class="type-annotation"><a href="dart_otp/OTPAlgorithm-class.html">OTPAlgorithm</a></span> <span class="parameter-name">algorithm</span>: <span class="default-value">OTPAlgorithm.SHA1</span></span> })</span>
</dt>
<dd>
This constructor will create an HOTP instance. <a href="dart_otp/HOTP/HOTP.html">[...]</a>
Expand Down Expand Up @@ -107,15 +110,15 @@ <h2>Properties</h2>
</dd>
<dt id="type" class="property">
<span class="name"><a href="dart_otp/HOTP/type.html">type</a></span>
<span class="signature">&#8594; OTPType</span>
<span class="signature">&#8594; <a href="dart_otp/OTPType-class.html">OTPType</a></span>
</dt>
<dd>
The type of the token.
<div class="features">read-only</div>
</dd>
<dt id="algorithm" class="property inherited">
<span class="name"><a href="dart_otp/HOTP/algorithm.html">algorithm</a></span>
<span class="signature">&#8596; OTPAlgorithm</span>
<span class="signature">&#8596; <a href="dart_otp/OTPAlgorithm-class.html">OTPAlgorithm</a></span>
</dt>
<dd class="inherited">
The crypto algorithm used on HMAC encoding.
Expand Down Expand Up @@ -178,7 +181,7 @@ <h2>Methods</h2>

</dd>
<dt id="generateOTP" class="callable inherited">
<span class="name"><a href="dart_otp/HOTP/generateOTP.html">generateOTP</a></span><span class="signature">(<wbr>{<span class="parameter" id="generateOTP-param-input"><span class="type-annotation">int</span> <span class="parameter-name">input</span>, </span> <span class="parameter" id="generateOTP-param-algorithm"><span class="type-annotation">OTPAlgorithm</span> <span class="parameter-name">algorithm</span>: <span class="default-value">OTPAlgorithm.SHA1</span></span> })
<span class="name"><a href="dart_otp/HOTP/generateOTP.html">generateOTP</a></span><span class="signature">(<wbr>{<span class="parameter" id="generateOTP-param-input"><span class="type-annotation">int</span> <span class="parameter-name">input</span>, </span> <span class="parameter" id="generateOTP-param-algorithm"><span class="type-annotation"><a href="dart_otp/OTPAlgorithm-class.html">OTPAlgorithm</a></span> <span class="parameter-name">algorithm</span>: <span class="default-value">OTPAlgorithm.SHA1</span></span> })
<span class="returntype parameter">&#8594; String</span>
</span>
</dt>
Expand Down Expand Up @@ -275,7 +278,7 @@ <h2>Operators</h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
4 changes: 2 additions & 2 deletions doc/api/dart_otp/HOTP/HOTP.html
Expand Up @@ -89,7 +89,7 @@ <h5>HOTP class</h5>

<section class="multi-line-signature">

<span class="name ">HOTP</span>(<wbr>{<span class="parameter" id="-param-secret"><span class="type-annotation">String</span> <span class="parameter-name">secret</span>, </span> <span class="parameter" id="-param-counter"><span class="type-annotation">int</span> <span class="parameter-name">counter</span>: <span class="default-value">0</span>, </span> <span class="parameter" id="-param-digits"><span class="type-annotation">int</span> <span class="parameter-name">digits</span>: <span class="default-value">6</span>, </span> <span class="parameter" id="-param-algorithm"><span class="type-annotation">OTPAlgorithm</span> <span class="parameter-name">algorithm</span>: <span class="default-value">OTPAlgorithm.SHA1</span></span> })
<span class="name ">HOTP</span>(<wbr>{<span class="parameter" id="-param-secret"><span class="type-annotation">String</span> <span class="parameter-name">secret</span>, </span> <span class="parameter" id="-param-counter"><span class="type-annotation">int</span> <span class="parameter-name">counter</span>: <span class="default-value">0</span>, </span> <span class="parameter" id="-param-digits"><span class="type-annotation">int</span> <span class="parameter-name">digits</span>: <span class="default-value">6</span>, </span> <span class="parameter" id="-param-algorithm"><span class="type-annotation"><a href="dart_otp/OTPAlgorithm-class.html">OTPAlgorithm</a></span> <span class="parameter-name">algorithm</span>: <span class="default-value">OTPAlgorithm.SHA1</span></span> })
</section>

<section class="desc markdown">
Expand Down Expand Up @@ -120,7 +120,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
4 changes: 2 additions & 2 deletions doc/api/dart_otp/HOTP/algorithm.html
Expand Up @@ -88,7 +88,7 @@ <h5>HOTP class</h5>
<div><h1><span class="kind-property">algorithm</span> property</h1></div>

<section class="multi-line-signature">
<span class="returntype">OTPAlgorithm</span>
<span class="returntype"><a href="dart_otp/OTPAlgorithm-class.html">OTPAlgorithm</a></span>
<span class="name ">algorithm</span>
<div class="features">read / write, inherited</div>
</section>
Expand All @@ -111,7 +111,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion doc/api/dart_otp/HOTP/at.html
Expand Up @@ -120,7 +120,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion doc/api/dart_otp/HOTP/counter.html
Expand Up @@ -111,7 +111,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion doc/api/dart_otp/HOTP/digits.html
Expand Up @@ -111,7 +111,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion doc/api/dart_otp/HOTP/extraUrlProperties.html
Expand Up @@ -115,7 +115,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
9 changes: 5 additions & 4 deletions doc/api/dart_otp/HOTP/generateOTP.html
Expand Up @@ -90,7 +90,7 @@ <h5>HOTP class</h5>
<section class="multi-line-signature">
<span class="returntype">String</span>
<span class="name ">generateOTP</span>
(<wbr>{<span class="parameter" id="generateOTP-param-input"><span class="type-annotation">int</span> <span class="parameter-name">input</span>, </span> <span class="parameter" id="generateOTP-param-algorithm"><span class="type-annotation">OTPAlgorithm</span> <span class="parameter-name">algorithm</span>: <span class="default-value">OTPAlgorithm.SHA1</span></span> })
(<wbr>{<span class="parameter" id="generateOTP-param-input"><span class="type-annotation">int</span> <span class="parameter-name">input</span>, </span> <span class="parameter" id="generateOTP-param-algorithm"><span class="type-annotation"><a href="dart_otp/OTPAlgorithm-class.html">OTPAlgorithm</a></span> <span class="parameter-name">algorithm</span>: <span class="default-value">OTPAlgorithm.SHA1</span></span> })
<div class="features">inherited</div>
</section>
<section class="desc markdown">
Expand All @@ -108,10 +108,11 @@ <h2><span>Implementation</span></h2>
var hmacKey = base32.decode(this.secret);

&#47;&#47;&#47; initial the HMAC-SHA1 object
var hmacSha1 = createHmacFor(algorithm: algorithm, key: hmacKey);
var hmacSha =
AlgorithmUtil.createHmacFor(algorithm: algorithm, key: hmacKey);

&#47;&#47;&#47; get hmac answer
var hmac = hmacSha1.convert(Util.intToBytelist(input: input)).bytes;
var hmac = hmacSha.convert(Util.intToBytelist(input: input)).bytes;

&#47;&#47;&#47; calculate the init offset
int offset = hmac[hmac.length - 1] &amp; 0xf;
Expand Down Expand Up @@ -139,7 +140,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
6 changes: 3 additions & 3 deletions doc/api/dart_otp/HOTP/generateUrl.html
Expand Up @@ -103,11 +103,11 @@ <h5>HOTP class</h5>
<h2><span>Implementation</span></h2>
<pre class="language-dart"><code class="language-dart">String generateUrl({String issuer, String account}) {
final _secret = this.secret;
final _type = otpTypeValue(type: type);
final _type = OTPUtil.otpTypeValue(type: type);
final _account = Uri.encodeComponent(account ?? &#39;&#39;);
final _issuer = Uri.encodeQueryComponent(issuer ?? &#39;&#39;);

final _algorithm = rawValue(algorithm: algorithm);
final _algorithm = AlgorithmUtil.rawValue(algorithm: algorithm);
final _extra = extraUrlProperties
.map((key, value) =&gt; MapEntry(key, &quot;$key=$value&quot;))
.values
Expand All @@ -126,7 +126,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion doc/api/dart_otp/HOTP/hashCode.html
Expand Up @@ -136,7 +136,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion doc/api/dart_otp/HOTP/noSuchMethod.html
Expand Up @@ -116,7 +116,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion doc/api/dart_otp/HOTP/operator_equals.html
Expand Up @@ -129,7 +129,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion doc/api/dart_otp/HOTP/runtimeType.html
Expand Up @@ -115,7 +115,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion doc/api/dart_otp/HOTP/secret.html
Expand Up @@ -111,7 +111,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion doc/api/dart_otp/HOTP/toString.html
Expand Up @@ -112,7 +112,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
4 changes: 2 additions & 2 deletions doc/api/dart_otp/HOTP/type.html
Expand Up @@ -91,7 +91,7 @@ <h5>HOTP class</h5>
<section id="getter">

<section class="multi-line-signature">
<span class="returntype">OTPType</span>
<span class="returntype"><a href="dart_otp/OTPType-class.html">OTPType</a></span>
<span class="name ">type</span>

</section>
Expand All @@ -115,7 +115,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion doc/api/dart_otp/HOTP/urlGen.html
Expand Up @@ -121,7 +121,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down
2 changes: 1 addition & 1 deletion doc/api/dart_otp/HOTP/verify.html
Expand Up @@ -126,7 +126,7 @@ <h2><span>Implementation</span></h2>

<footer>
<span class="no-break">
dart_otp 1.2.0
dart_otp 1.3.0
</span>


Expand Down

0 comments on commit 4b35560

Please sign in to comment.