This repository has been archived by the owner on Dec 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The implementation is based on Reflectable, a library that does efficient reflection in Dart. So, instead of registering all implemented algorithms manually, the implementation itself defines how it should be registered. The Registry class will then search through all imported cipher.* libraries to look for implementations to include. This allows users to import api.dart and cherry pick certain implementations and still be able to use the generic constructors. It also makes it easier to add new implementations, adding a new file is all that it takes. This also allows external libraries to add implementations to cipher, just by creating cipher.* libraries and importing them. A side change is that I had to create a separate class for all ec curves. This positive side of this is again that users that only need one curve, don't have to import all curves. Other changes: I moves the CTRStreamCipher and SICStreamCipher modes into the cipher.stream namespace and created CTRBlockCipher and SICBlockCipher using the StreamCipherAsBlockCipher class for completeness.
- Loading branch information
1 parent
b8d5170
commit 2da75e5
Showing
121 changed files
with
1,901 additions
and
1,215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,6 @@ pubspec.lock | |
*.iml | ||
|
||
# dartdoc | ||
doc/ | ||
doc/ | ||
|
||
.pub/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2013-present, Iván Zaera Avellón - izaera@gmail.com | ||
|
||
// This library is dually licensed under LGPL 3 and MPL 2.0. See file LICENSE for more information. | ||
|
||
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of | ||
// the MPL was not distributed with this file, you can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
library cipher.block_cipher.modes.ctr; | ||
|
||
import "package:cipher/api.dart"; | ||
import "package:cipher/adapters/stream_cipher_as_block_cipher.dart"; | ||
import "package:cipher/stream/ctr.dart"; | ||
import "package:cipher/src/registry/registry.dart"; | ||
|
||
class CTRBlockCipher extends StreamCipherAsBlockCipher { | ||
|
||
/// Intended for internal use. | ||
static final FactoryConfig FACTORY_CONFIG = | ||
new DynamicFactoryConfig.suffix("/CTR", (final String algorithmName, _) => () { | ||
int sep = algorithmName.lastIndexOf("/"); | ||
BlockCipher underlying = new BlockCipher(algorithmName.substring(0, sep)); | ||
return new CTRBlockCipher(underlying.blockSize, new CTRStreamCipher(underlying)); | ||
}); | ||
|
||
CTRBlockCipher(int blockSize, StreamCipher underlyingCipher) | ||
: super(blockSize, underlyingCipher); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2013-present, Iván Zaera Avellón - izaera@gmail.com | ||
|
||
// This library is dually licensed under LGPL 3 and MPL 2.0. See file LICENSE for more information. | ||
|
||
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of | ||
// the MPL was not distributed with this file, you can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
library cipher.block_cipher.modes.sic; | ||
|
||
import "package:cipher/api.dart"; | ||
import "package:cipher/adapters/stream_cipher_as_block_cipher.dart"; | ||
import "package:cipher/stream/sic.dart"; | ||
import "package:cipher/src/registry/registry.dart"; | ||
|
||
class SICBlockCipher extends StreamCipherAsBlockCipher { | ||
|
||
/// Intended for internal use. | ||
static final FactoryConfig FACTORY_CONFIG = | ||
new DynamicFactoryConfig.suffix("/SIC", (final String algorithmName, _) => () { | ||
int sep = algorithmName.lastIndexOf("/"); | ||
BlockCipher underlying = new BlockCipher(algorithmName.substring(0, sep)); | ||
return new SICBlockCipher(underlying.blockSize, new SICStreamCipher(underlying)); | ||
}); | ||
|
||
SICBlockCipher(int blockSize, StreamCipher underlyingCipher) | ||
: super(blockSize, underlyingCipher); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.