Initial commit: 首次建仓,建立目录结构
This commit is contained in:
@ -0,0 +1,32 @@
|
||||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import abc
|
||||
|
||||
from cryptography.utils import Buffer
|
||||
|
||||
|
||||
class KeyDerivationFunction(metaclass=abc.ABCMeta):
|
||||
@abc.abstractmethod
|
||||
def derive(self, key_material: bytes) -> bytes:
|
||||
"""
|
||||
Deterministically generates and returns a new key based on the existing
|
||||
key material.
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def derive_into(self, key_material: bytes, buffer: Buffer) -> None:
|
||||
"""
|
||||
Deterministically generates a new key based on the existing key
|
||||
material and stores it in the provided buffer.
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None:
|
||||
"""
|
||||
Checks whether the key generated by the key material matches the
|
||||
expected derived key. Raises an exception if they do not match.
|
||||
"""
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,17 @@
|
||||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
Argon2d = rust_openssl.kdf.Argon2d
|
||||
Argon2i = rust_openssl.kdf.Argon2i
|
||||
Argon2id = rust_openssl.kdf.Argon2id
|
||||
KeyDerivationFunction.register(Argon2d)
|
||||
KeyDerivationFunction.register(Argon2i)
|
||||
KeyDerivationFunction.register(Argon2id)
|
||||
|
||||
__all__ = ["Argon2d", "Argon2i", "Argon2id"]
|
||||
@ -0,0 +1,16 @@
|
||||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
ConcatKDFHash = rust_openssl.kdf.ConcatKDFHash
|
||||
ConcatKDFHMAC = rust_openssl.kdf.ConcatKDFHMAC
|
||||
|
||||
KeyDerivationFunction.register(ConcatKDFHash)
|
||||
KeyDerivationFunction.register(ConcatKDFHMAC)
|
||||
|
||||
__all__ = ["ConcatKDFHMAC", "ConcatKDFHash"]
|
||||
@ -0,0 +1,16 @@
|
||||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
HKDF = rust_openssl.kdf.HKDF
|
||||
HKDFExpand = rust_openssl.kdf.HKDFExpand
|
||||
|
||||
KeyDerivationFunction.register(HKDF)
|
||||
KeyDerivationFunction.register(HKDFExpand)
|
||||
|
||||
__all__ = ["HKDF", "HKDFExpand"]
|
||||
@ -0,0 +1,26 @@
|
||||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from cryptography import utils
|
||||
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
|
||||
class Mode(utils.Enum):
|
||||
CounterMode = "ctr"
|
||||
|
||||
|
||||
class CounterLocation(utils.Enum):
|
||||
BeforeFixed = "before_fixed"
|
||||
AfterFixed = "after_fixed"
|
||||
MiddleFixed = "middle_fixed"
|
||||
|
||||
|
||||
KBKDFHMAC = rust_openssl.kdf.KBKDFHMAC
|
||||
KeyDerivationFunction.register(KBKDFHMAC)
|
||||
|
||||
KBKDFCMAC = rust_openssl.kdf.KBKDFCMAC
|
||||
KeyDerivationFunction.register(KBKDFCMAC)
|
||||
@ -0,0 +1,13 @@
|
||||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
PBKDF2HMAC = rust_openssl.kdf.PBKDF2HMAC
|
||||
KeyDerivationFunction.register(PBKDF2HMAC)
|
||||
|
||||
__all__ = ["PBKDF2HMAC"]
|
||||
@ -0,0 +1,19 @@
|
||||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
# This is used by the scrypt tests to skip tests that require more memory
|
||||
# than the MEM_LIMIT
|
||||
_MEM_LIMIT = sys.maxsize // 2
|
||||
|
||||
Scrypt = rust_openssl.kdf.Scrypt
|
||||
KeyDerivationFunction.register(Scrypt)
|
||||
|
||||
__all__ = ["Scrypt"]
|
||||
@ -0,0 +1,13 @@
|
||||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
X963KDF = rust_openssl.kdf.X963KDF
|
||||
KeyDerivationFunction.register(X963KDF)
|
||||
|
||||
__all__ = ["X963KDF"]
|
||||
Reference in New Issue
Block a user