mirror of
https://github.com/apple/swift-crypto
synced 2026-11-22 04:30:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2f3774fd1 | ||
|
|
a84771015f | ||
|
|
2934bb4cf8 | ||
|
|
0bf9f479b8 | ||
|
|
bce1725222 | ||
|
|
555b9f1dab | ||
|
|
600eda380a | ||
|
|
865068322c | ||
|
|
dc4c2c14e7 | ||
|
|
0ec5ca1e3f | ||
|
|
bd94260799 | ||
|
|
ff0f781cf7 | ||
|
|
a3b7196be9 | ||
|
|
b6a32eb851 | ||
|
|
e14f4bb065 | ||
|
|
06dc63c6d8 | ||
|
|
62958ed575 | ||
|
|
e9d46e7bf9 | ||
|
|
8fa345c208 | ||
|
|
7cb61135cb | ||
|
|
4518e5e680 | ||
|
|
4324b40570 | ||
|
|
f98e46e42a | ||
|
|
ae321d29be | ||
|
|
21f7878f2b | ||
|
|
735a29ccf7 | ||
|
|
b639b5bd1f | ||
|
|
ffca28be3c | ||
|
|
35703579f6 | ||
|
|
a24950b8aa | ||
|
|
e8f2ddd49e | ||
|
|
55201a8f83 | ||
|
|
81bee98e70 | ||
|
|
ce204da6f6 | ||
|
|
9f95b4d033 | ||
|
|
a53a7e8f85 | ||
|
|
8dafe0fdce | ||
|
|
e2dd5a547b | ||
|
|
46072478ca | ||
|
|
c370ad81a1 | ||
|
|
33f65a3cbc | ||
|
|
fdfdc11707 | ||
|
|
a3866d45d9 | ||
|
|
5fb3819b51 | ||
|
|
3c060cc4af | ||
|
|
c36d19a064 | ||
|
|
bc1c29221f | ||
|
|
2adec617e6 | ||
|
|
89876ab72c | ||
|
|
f0525da24d | ||
|
|
52d0d9f15a | ||
|
|
9960a73340 | ||
|
|
606608da08 | ||
|
|
029eeacda4 | ||
|
|
cc76b89416 | ||
|
|
3e8497753e | ||
|
|
c1825df19b | ||
|
|
09f7a993f6 | ||
|
|
ed66091040 | ||
|
|
b793a1e564 | ||
|
|
f4b21dbde7 | ||
|
|
3df7fa0626 | ||
|
|
7644bdcc76 | ||
|
|
fade397763 | ||
|
|
c4f2e9938a |
No files matched your search
@@ -0,0 +1,8 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
@@ -9,7 +9,7 @@ about: If something isn't working as expected
|
||||
### New Issue Checklist
|
||||
|
||||
- [ ] I'm using the latest version of Swift Crypto (`main` branch)
|
||||
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/master/CONTRIBUTING.md)
|
||||
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/main/CONTRIBUTING.md)
|
||||
- [ ] I searched for [existing GitHub issues](https://github.com/apple/swift-crypto/issues)
|
||||
|
||||
### Expected behavior
|
||||
|
||||
@@ -6,8 +6,8 @@ about: Not sure how something works or how to implement some functionality? Ask
|
||||
|
||||
### Question Checklist
|
||||
|
||||
- [ ] I'm using the latest version of Swift Crypto (master branch)
|
||||
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/master/CONTRIBUTING.md)
|
||||
- [ ] I'm using the latest version of Swift Crypto (main branch)
|
||||
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/main/CONTRIBUTING.md)
|
||||
- [ ] I searched for [existing GitHub issues](https://github.com/apple/swift-crypto/issues)
|
||||
|
||||
### Question Subject
|
||||
|
||||
@@ -8,8 +8,8 @@ about: If a recent release broke a feature (Please make sure you know the last k
|
||||
|
||||
### New Regression Checklist
|
||||
|
||||
- [ ] I'm using the latest version of Swift Crypto (master branch)
|
||||
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/master/CONTRIBUTING.md)
|
||||
- [ ] I'm using the latest version of Swift Crypto (main branch)
|
||||
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/main/CONTRIBUTING.md)
|
||||
- [ ] I searched for [existing GitHub issues](https://github.com/apple/swift-crypto/issues)
|
||||
|
||||
### Regression Information
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
changelog:
|
||||
categories:
|
||||
- title: SemVer Major
|
||||
labels:
|
||||
- ⚠️ semver/major
|
||||
- title: SemVer Minor
|
||||
labels:
|
||||
- 🆕 semver/minor
|
||||
- title: SemVer Patch
|
||||
labels:
|
||||
- 🔨 semver/patch
|
||||
- title: Other Changes
|
||||
labels:
|
||||
- semver/none
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Main
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: "0 8,20 * * *"
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
name: Unit tests
|
||||
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
|
||||
with:
|
||||
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
linux_nightly_6_1_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
|
||||
cxx-interop:
|
||||
name: Cxx interop
|
||||
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
|
||||
@@ -0,0 +1,40 @@
|
||||
name: PR
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
jobs:
|
||||
soundness:
|
||||
name: Soundness
|
||||
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
|
||||
with:
|
||||
license_header_check_project_name: "SwiftCrypto"
|
||||
docs_check_enabled: false
|
||||
|
||||
cmake-lists:
|
||||
name: Check cmake lists
|
||||
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
|
||||
with:
|
||||
name: "Check cmake lists"
|
||||
matrix_linux_command: ./scripts/check-cmake-lists.sh
|
||||
|
||||
unit-tests:
|
||||
name: Unit tests
|
||||
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
|
||||
with:
|
||||
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
linux_nightly_6_1_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
windows_6_0_enabled: true
|
||||
windows_nightly_6_1_enabled: true
|
||||
windows_nightly_main_enabled: true
|
||||
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
windows_nightly_6_1_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
|
||||
cxx-interop:
|
||||
name: Cxx interop
|
||||
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
|
||||
@@ -0,0 +1,18 @@
|
||||
name: PR label
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [labeled, unlabeled, opened, reopened, synchronize]
|
||||
|
||||
jobs:
|
||||
semver-label-check:
|
||||
name: Semantic version label check
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 1
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Check for Semantic Version label
|
||||
uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main
|
||||
@@ -15,3 +15,4 @@ DerivedData
|
||||
|
||||
.*.sw[nop]
|
||||
|
||||
.vscode
|
||||
@@ -0,0 +1,49 @@
|
||||
.gitignore
|
||||
**/.gitignore
|
||||
.licenseignore
|
||||
.unacceptablelanguageignore
|
||||
.swiftformatignore
|
||||
.gitattributes
|
||||
.git-blame-ignore-revs
|
||||
.mailfilter
|
||||
.mailmap
|
||||
.spi.yml
|
||||
.swift-format
|
||||
.editorconfig
|
||||
.github/*
|
||||
*.md
|
||||
*.txt
|
||||
*.yml
|
||||
*.yaml
|
||||
*.json
|
||||
Package.swift
|
||||
**/Package.swift
|
||||
Package@-*.swift
|
||||
**/Package@-*.swift
|
||||
Package.resolved
|
||||
**/Package.resolved
|
||||
Makefile
|
||||
*.modulemap
|
||||
**/*.modulemap
|
||||
**/*.docc/*
|
||||
*.xcprivacy
|
||||
**/*.xcprivacy
|
||||
*.symlink
|
||||
**/*.symlink
|
||||
Dockerfile
|
||||
**/Dockerfile
|
||||
Snippets/*
|
||||
dev/git.commit.template
|
||||
dev/update-benchmark-thresholds
|
||||
*.crt
|
||||
**/*.crt
|
||||
*.pem
|
||||
**/*.pem
|
||||
*.der
|
||||
**/*.der
|
||||
.swiftformat
|
||||
Sources/CCryptoBoringSSL/*
|
||||
**/*.swift.gyb
|
||||
scripts/*.patch
|
||||
scripts/gyb
|
||||
scripts/gyb.py
|
||||
@@ -0,0 +1,5 @@
|
||||
version: 1
|
||||
builder:
|
||||
configs:
|
||||
- documentation_targets: [Crypto, _CryptoExtras]
|
||||
platform: linux
|
||||
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"version" : 1,
|
||||
"indentation" : {
|
||||
"spaces" : 4
|
||||
},
|
||||
"tabWidth" : 4,
|
||||
"fileScopedDeclarationPrivacy" : {
|
||||
"accessLevel" : "private"
|
||||
},
|
||||
"spacesAroundRangeFormationOperators" : false,
|
||||
"indentConditionalCompilationBlocks" : false,
|
||||
"indentSwitchCaseLabels" : false,
|
||||
"lineBreakAroundMultilineExpressionChainComponents" : false,
|
||||
"lineBreakBeforeControlFlowKeywords" : false,
|
||||
"lineBreakBeforeEachArgument" : true,
|
||||
"lineBreakBeforeEachGenericRequirement" : true,
|
||||
"lineLength" : 120,
|
||||
"maximumBlankLines" : 1,
|
||||
"respectsExistingLineBreaks" : true,
|
||||
"prioritizeKeepingFunctionOutputTogether" : true,
|
||||
"rules" : {
|
||||
"AllPublicDeclarationsHaveDocumentation" : false,
|
||||
"AlwaysUseLiteralForEmptyCollectionInit" : false,
|
||||
"AlwaysUseLowerCamelCase" : false,
|
||||
"AmbiguousTrailingClosureOverload" : true,
|
||||
"BeginDocumentationCommentWithOneLineSummary" : false,
|
||||
"DoNotUseSemicolons" : true,
|
||||
"DontRepeatTypeInStaticProperties" : true,
|
||||
"FileScopedDeclarationPrivacy" : true,
|
||||
"FullyIndirectEnum" : true,
|
||||
"GroupNumericLiterals" : true,
|
||||
"IdentifiersMustBeASCII" : true,
|
||||
"NeverForceUnwrap" : false,
|
||||
"NeverUseForceTry" : false,
|
||||
"NeverUseImplicitlyUnwrappedOptionals" : false,
|
||||
"NoAccessLevelOnExtensionDeclaration" : true,
|
||||
"NoAssignmentInExpressions" : true,
|
||||
"NoBlockComments" : true,
|
||||
"NoCasesWithOnlyFallthrough" : true,
|
||||
"NoEmptyTrailingClosureParentheses" : true,
|
||||
"NoLabelsInCasePatterns" : true,
|
||||
"NoLeadingUnderscores" : false,
|
||||
"NoParensAroundConditions" : true,
|
||||
"NoVoidReturnOnFunctionSignature" : true,
|
||||
"OmitExplicitReturns" : true,
|
||||
"OneCasePerLine" : true,
|
||||
"OneVariableDeclarationPerLine" : true,
|
||||
"OnlyOneTrailingClosureArgument" : true,
|
||||
"OrderedImports" : true,
|
||||
"ReplaceForEachWithForLoop" : true,
|
||||
"ReturnVoidInsteadOfEmptyTuple" : true,
|
||||
"UseEarlyExits" : false,
|
||||
"UseExplicitNilCheckInConditions" : false,
|
||||
"UseLetInEveryBoundCaseVariable" : false,
|
||||
"UseShorthandTypeNames" : true,
|
||||
"UseSingleLinePropertyGetter" : false,
|
||||
"UseSynthesizedInitializer" : false,
|
||||
"UseTripleSlashForDocumentationComments" : true,
|
||||
"UseWhereClausesInForLoops" : false,
|
||||
"ValidateDocumentationComments" : false
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
# file options
|
||||
|
||||
--swiftversion 5.4
|
||||
--exclude .build
|
||||
|
||||
# format options
|
||||
|
||||
--self insert
|
||||
--patternlet inline
|
||||
--stripunusedargs unnamed-only
|
||||
--ifdef no-indent
|
||||
|
||||
# rules
|
||||
@@ -0,0 +1,141 @@
|
||||
Package.swift
|
||||
Sources/Crypto/AEADs/AES/GCM/AES-GCM.swift
|
||||
Sources/Crypto/AEADs/ChachaPoly/ChaChaPoly.swift
|
||||
Sources/Crypto/AEADs/Cipher.swift
|
||||
Sources/Crypto/AEADs/Nonces.swift
|
||||
Sources/Crypto/ASN1/ASN1.swift
|
||||
Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Any.swift
|
||||
Sources/Crypto/ASN1/Basic ASN1 Types/ASN1BitString.swift
|
||||
Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Boolean.swift
|
||||
Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Identifier.swift
|
||||
Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Integer.swift
|
||||
Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Null.swift
|
||||
Sources/Crypto/ASN1/Basic ASN1 Types/ASN1OctetString.swift
|
||||
Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Strings.swift
|
||||
Sources/Crypto/ASN1/Basic ASN1 Types/ArraySliceBigint.swift
|
||||
Sources/Crypto/ASN1/Basic ASN1 Types/GeneralizedTime.swift
|
||||
Sources/Crypto/ASN1/Basic ASN1 Types/ObjectIdentifier.swift
|
||||
Sources/Crypto/ASN1/ECDSASignature.swift
|
||||
Sources/Crypto/ASN1/PEMDocument.swift
|
||||
Sources/Crypto/ASN1/PKCS8PrivateKey.swift
|
||||
Sources/Crypto/ASN1/SEC1PrivateKey.swift
|
||||
Sources/Crypto/ASN1/SubjectPublicKeyInfo.swift
|
||||
Sources/Crypto/CryptoKitErrors.swift
|
||||
Sources/Crypto/Digests/Digest.swift
|
||||
Sources/Crypto/Digests/Digests.swift
|
||||
Sources/Crypto/Digests/HashFunctions.swift
|
||||
Sources/Crypto/Digests/HashFunctions_SHA2.swift
|
||||
Sources/Crypto/HPKE/Ciphersuite/HPKE-AEAD.swift
|
||||
Sources/Crypto/HPKE/Ciphersuite/HPKE-Ciphersuite.swift
|
||||
Sources/Crypto/HPKE/Ciphersuite/HPKE-KDF.swift
|
||||
Sources/Crypto/HPKE/Ciphersuite/HPKE-KexKeyDerivation.swift
|
||||
Sources/Crypto/HPKE/Ciphersuite/HPKE-LabeledExtract.swift
|
||||
Sources/Crypto/HPKE/Ciphersuite/HPKE-Utils.swift
|
||||
Sources/Crypto/HPKE/Ciphersuite/KEM/Conformances/DHKEM.swift
|
||||
Sources/Crypto/HPKE/Ciphersuite/KEM/Conformances/HPKE-KEM-Curve25519.swift
|
||||
Sources/Crypto/HPKE/Ciphersuite/KEM/Conformances/HPKE-NIST-EC-KEMs.swift
|
||||
Sources/Crypto/HPKE/Ciphersuite/KEM/HPKE-KEM.swift
|
||||
Sources/Crypto/HPKE/HPKE-Errors.swift
|
||||
Sources/Crypto/HPKE/HPKE.swift
|
||||
Sources/Crypto/HPKE/Key Schedule/HPKE-Context.swift
|
||||
Sources/Crypto/HPKE/Key Schedule/HPKE-KeySchedule.swift
|
||||
Sources/Crypto/HPKE/Modes/HPKE-Modes.swift
|
||||
Sources/Crypto/Insecure/Insecure.swift
|
||||
Sources/Crypto/Insecure/Insecure_HashFunctions.swift
|
||||
Sources/Crypto/KEM/KEM.swift
|
||||
Sources/Crypto/Key Agreement/DH.swift
|
||||
Sources/Crypto/Key Agreement/ECDH.swift
|
||||
Sources/Crypto/Key Derivation/HKDF.swift
|
||||
Sources/Crypto/Key Wrapping/AESWrap.swift
|
||||
Sources/Crypto/Keys/EC/Curve25519.swift
|
||||
Sources/Crypto/Keys/EC/Ed25519Keys.swift
|
||||
Sources/Crypto/Keys/EC/NISTCurvesKeys.swift
|
||||
Sources/Crypto/Keys/EC/X25519Keys.swift
|
||||
Sources/Crypto/Keys/Symmetric/SymmetricKeys.swift
|
||||
Sources/Crypto/Message Authentication Codes/HMAC/HMAC.swift
|
||||
Sources/Crypto/Message Authentication Codes/MACFunctions.swift
|
||||
Sources/Crypto/Message Authentication Codes/MessageAuthenticationCode.swift
|
||||
Sources/Crypto/PRF/AES.swift
|
||||
Sources/Crypto/Signatures/ECDSA.swift
|
||||
Sources/Crypto/Signatures/Ed25519.swift
|
||||
Sources/Crypto/Signatures/Signature.swift
|
||||
Sources/Crypto/Util/PrettyBytes.swift
|
||||
Sources/Crypto/Util/SafeCompare.swift
|
||||
Sources/Crypto/Util/SecureBytes.swift
|
||||
Sources/Crypto/Util/Zeroization.swift
|
||||
Sources/_CryptoExtras/AES/AES_CBC.swift
|
||||
Sources/_CryptoExtras/AES/AES_CFB.swift
|
||||
Sources/_CryptoExtras/AES/AES_CTR.swift
|
||||
Sources/_CryptoExtras/AES/AES_GCM_SIV.swift
|
||||
Sources/_CryptoExtras/AES/Block Function.swift
|
||||
Sources/_CryptoExtras/ChaCha20CTR/ChaCha20CTR.swift
|
||||
Sources/_CryptoExtras/ECToolbox/ECToolbox.swift
|
||||
Sources/_CryptoExtras/H2G/HashToField.swift
|
||||
Sources/_CryptoExtras/Key Derivation/KDF.swift
|
||||
Sources/_CryptoExtras/Key Derivation/PBKDF2/PBKDF2.swift
|
||||
Sources/_CryptoExtras/Key Derivation/Scrypt/Scrypt.swift
|
||||
Sources/_CryptoExtras/OPRFs/OPRF.swift
|
||||
Sources/_CryptoExtras/OPRFs/OPRFClient.swift
|
||||
Sources/_CryptoExtras/OPRFs/OPRFServer.swift
|
||||
Sources/_CryptoExtras/OPRFs/VOPRF+API.swift
|
||||
Sources/_CryptoExtras/OPRFs/VOPRFClient.swift
|
||||
Sources/_CryptoExtras/OPRFs/VOPRFServer.swift
|
||||
Sources/_CryptoExtras/RSA/RSA+BlindSigning.swift
|
||||
Sources/_CryptoExtras/RSA/RSA.swift
|
||||
Sources/_CryptoExtras/RSA/RSA_security.swift
|
||||
Sources/_CryptoExtras/Util/BoringSSLHelpers.swift
|
||||
Sources/_CryptoExtras/Util/DigestType.swift
|
||||
Sources/_CryptoExtras/Util/Error.swift
|
||||
Sources/_CryptoExtras/Util/I2OSP.swift
|
||||
Sources/_CryptoExtras/Util/PEMDocument.swift
|
||||
Sources/_CryptoExtras/Util/PrettyBytes.swift
|
||||
Sources/_CryptoExtras/Util/SubjectPublicKeyInfo.swift
|
||||
Sources/_CryptoExtras/ZKPs/DLEQ.swift
|
||||
Sources/crypto-shasum/main.swift
|
||||
Tests/CryptoTests/ASN1/ASN1Tests.swift
|
||||
Tests/CryptoTests/ASN1/GeneralizedTimeTests.swift
|
||||
Tests/CryptoTests/Authenticated Encryption/AES-GCM-Runner.swift
|
||||
Tests/CryptoTests/Authenticated Encryption/ChaChaPoly-Runner.swift
|
||||
Tests/CryptoTests/Digests/DigestsTests.swift
|
||||
Tests/CryptoTests/ECDH/X25519-Runner.swift
|
||||
Tests/CryptoTests/ECDH/secpECDH_Runner.swift
|
||||
Tests/CryptoTests/Encodings/DERTests.swift
|
||||
Tests/CryptoTests/Encodings/ECKeyEncodingsTests.swift
|
||||
Tests/CryptoTests/HPKE/HPKETests-TestVectors.swift
|
||||
Tests/CryptoTests/HPKE/HPKETests.swift
|
||||
Tests/CryptoTests/Key Derivation/ECprivateKeysFromSeeds.swift
|
||||
Tests/CryptoTests/Key Derivation/HKDFTests.swift
|
||||
Tests/CryptoTests/Key Derivation/SharedSecretTests.swift
|
||||
Tests/CryptoTests/Key Derivation/X963KDFTests.swift
|
||||
Tests/CryptoTests/Key Wrapping/KeyWrapping.swift
|
||||
Tests/CryptoTests/MAC/HMACTests.swift
|
||||
Tests/CryptoTests/SecureBytes/SecureBytesTests.swift
|
||||
Tests/CryptoTests/Signatures/ECDSA/ECDSASignatureTests.swift
|
||||
Tests/CryptoTests/Signatures/ECDSA/RawECDSASignaturesTests.swift
|
||||
Tests/CryptoTests/Signatures/EdDSA/Ed25519-Runner.swift
|
||||
Tests/CryptoTests/Utils/PrettyBytes.swift
|
||||
Tests/CryptoTests/Utils/RFCVector.swift
|
||||
Tests/CryptoTests/Utils/SplitData.swift
|
||||
Tests/CryptoTests/Utils/Wycheproof.swift
|
||||
Tests/CryptoTests/Utils/XCTestUtils.swift
|
||||
Tests/_CryptoExtrasTests/AES Block Function Tests.swift
|
||||
Tests/_CryptoExtrasTests/AES-GCM-SIV-Runner.swift
|
||||
Tests/_CryptoExtrasTests/AES_CBCTests.swift
|
||||
Tests/_CryptoExtrasTests/AES_CFBTests.swift
|
||||
Tests/_CryptoExtrasTests/AES_CTRTests.swift
|
||||
Tests/_CryptoExtrasTests/ChaCha20CTRTests.swift
|
||||
Tests/_CryptoExtrasTests/ECToolbox/HashToCurveTests.swift
|
||||
Tests/_CryptoExtrasTests/OPRFs/ECVOPRFTests.swift
|
||||
Tests/_CryptoExtrasTests/OPRFs/VOPRFAPITests.swift
|
||||
Tests/_CryptoExtrasTests/OPRFs/VOPRFPublicAPITests.swift
|
||||
Tests/_CryptoExtrasTests/PBKDF2Tests.swift
|
||||
Tests/_CryptoExtrasTests/ScryptTests.swift
|
||||
Tests/_CryptoExtrasTests/TestRSABlindSigning.swift
|
||||
Tests/_CryptoExtrasTests/TestRSABlindSigningAPI.swift
|
||||
Tests/_CryptoExtrasTests/TestRSAEncryption.swift
|
||||
Tests/_CryptoExtrasTests/TestRSASigning.swift
|
||||
Tests/_CryptoExtrasTests/Utils/BytesUtil.swift
|
||||
Tests/_CryptoExtrasTests/Utils/RFCVector.swift
|
||||
Tests/_CryptoExtrasTests/Utils/SplitData.swift
|
||||
Tests/_CryptoExtrasTests/Utils/Wycheproof.swift
|
||||
Tests/_CryptoExtrasTests/Utils/XCTestUtils.swift
|
||||
@@ -0,0 +1 @@
|
||||
Sources/CCryptoBoringSSL/*
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<array/>
|
||||
</plist>
|
||||
+15
-1
@@ -6,7 +6,7 @@
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
## See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
@@ -31,6 +31,10 @@ endif()
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
|
||||
|
||||
set(SWIFT_CRYPTO_COMPILE_OPTIONS
|
||||
-package-name com.apple.swift-crypto
|
||||
)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
@@ -48,5 +52,15 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
find_package(Foundation CONFIG)
|
||||
endif()
|
||||
|
||||
include(FetchContent)
|
||||
find_package(SwiftASN1 CONFIG)
|
||||
if(NOT SwiftASN1_FOUND)
|
||||
message("-- Vending swift-asn1")
|
||||
FetchContent_Declare(ASN1
|
||||
GIT_REPOSITORY https://github.com/apple/swift-asn1
|
||||
GIT_TAG 1.1.0)
|
||||
FetchContent_MakeAvailable(ASN1)
|
||||
endif()
|
||||
|
||||
add_subdirectory(Sources)
|
||||
add_subdirectory(cmake/modules)
|
||||
File renamed without changes.
+1
-1
@@ -28,7 +28,7 @@ components that this product depends on.
|
||||
This product contains test vectors from Google's wycheproof project.
|
||||
|
||||
* LICENSE (Apache License 2.0):
|
||||
* https://github.com/google/wycheproof/blob/master/LICENSE
|
||||
* https://github.com/C2SP/wycheproof/blob/31387e2cd596587c859c611027b6a44d2e2b65ff/LICENSE
|
||||
* HOMEPAGE:
|
||||
* https://github.com/google/wycheproof
|
||||
|
||||
|
||||
+83
-27
@@ -1,4 +1,4 @@
|
||||
// swift-tools-version:5.7
|
||||
// swift-tools-version:5.9
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the SwiftCrypto open source project
|
||||
@@ -7,7 +7,7 @@
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
// See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
// See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
@@ -20,16 +20,25 @@
|
||||
// Sources/CCryptoBoringSSL directory. The source repository is at
|
||||
// https://boringssl.googlesource.com/boringssl.
|
||||
//
|
||||
// BoringSSL Commit: 7ae2b910c13017b63f1a8bd6c8decfce692869b0
|
||||
// BoringSSL Commit: aefa5d24da34ef77ac797bdbe684734e5bd870f4
|
||||
|
||||
import PackageDescription
|
||||
|
||||
// To develop this on Apple platforms, set this to true
|
||||
let development = false
|
||||
|
||||
// Ideally, we should use `.when(platforms:)` to set `swiftSettings` and
|
||||
// `dependencies` like on other platforms. However, `Platform.freebsd` is not
|
||||
// yet available, and therefore we guard the settings behind this boolean.
|
||||
#if os(FreeBSD)
|
||||
let isFreeBSD = true
|
||||
#else
|
||||
let isFreeBSD = false
|
||||
#endif
|
||||
|
||||
let swiftSettings: [SwiftSetting]
|
||||
let dependencies: [Target.Dependency]
|
||||
if development {
|
||||
if development || isFreeBSD {
|
||||
swiftSettings = [
|
||||
.define("CRYPTO_IN_SWIFTPM"),
|
||||
.define("CRYPTO_IN_SWIFTPM_FORCE_BUILD_API"),
|
||||
@@ -37,14 +46,14 @@ if development {
|
||||
dependencies = [
|
||||
"CCryptoBoringSSL",
|
||||
"CCryptoBoringSSLShims",
|
||||
"CryptoBoringWrapper"
|
||||
"CryptoBoringWrapper",
|
||||
]
|
||||
} else {
|
||||
let platforms: [Platform] = [
|
||||
Platform.linux,
|
||||
Platform.android,
|
||||
Platform.windows,
|
||||
Platform.wasi,
|
||||
Platform.wasi
|
||||
]
|
||||
swiftSettings = [
|
||||
.define("CRYPTO_IN_SWIFTPM"),
|
||||
@@ -53,10 +62,22 @@ if development {
|
||||
dependencies = [
|
||||
.target(name: "CCryptoBoringSSL", condition: .when(platforms: platforms)),
|
||||
.target(name: "CCryptoBoringSSLShims", condition: .when(platforms: platforms)),
|
||||
.target(name: "CryptoBoringWrapper", condition: .when(platforms: platforms))
|
||||
.target(name: "CryptoBoringWrapper", condition: .when(platforms: platforms)),
|
||||
]
|
||||
}
|
||||
|
||||
// This doesn't work when cross-compiling: the privacy manifest will be included in the Bundle and
|
||||
// Foundation will be linked. This is, however, strictly better than unconditionally adding the
|
||||
// resource.
|
||||
#if canImport(Darwin)
|
||||
let privacyManifestExclude: [String] = []
|
||||
let privacyManifestResource: [PackageDescription.Resource] = [.copy("PrivacyInfo.xcprivacy")]
|
||||
#else
|
||||
// Exclude on other platforms to avoid build warnings.
|
||||
let privacyManifestExclude: [String] = ["PrivacyInfo.xcprivacy"]
|
||||
let privacyManifestResource: [PackageDescription.Resource] = []
|
||||
#endif
|
||||
|
||||
let package = Package(
|
||||
name: "swift-crypto",
|
||||
platforms: [
|
||||
@@ -72,11 +93,13 @@ let package = Package(
|
||||
.library(name: "CCryptoBoringSSL", type: .static, targets: ["CCryptoBoringSSL"]),
|
||||
MANGLE_END */
|
||||
],
|
||||
dependencies: [],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/apple/swift-asn1.git", from: "1.2.0")
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "CCryptoBoringSSL",
|
||||
exclude: [
|
||||
exclude: privacyManifestExclude + [
|
||||
"hash.txt",
|
||||
"include/boringssl_prefix_symbols_nasm.inc",
|
||||
"CMakeLists.txt",
|
||||
@@ -84,10 +107,11 @@ let package = Package(
|
||||
* These files are excluded to support WASI libc which doesn't provide <netdb.h>.
|
||||
* This is safe for all platforms as we do not rely on networking features.
|
||||
*/
|
||||
"crypto/bio/connect.c",
|
||||
"crypto/bio/socket_helper.c",
|
||||
"crypto/bio/socket.c"
|
||||
"crypto/bio/connect.cc",
|
||||
"crypto/bio/socket_helper.cc",
|
||||
"crypto/bio/socket.cc"
|
||||
],
|
||||
resources: privacyManifestResource,
|
||||
cSettings: [
|
||||
// These defines come from BoringSSL's build system
|
||||
.define("_HAS_EXCEPTIONS", to: "0", .when(platforms: [Platform.windows])),
|
||||
@@ -97,27 +121,32 @@ let package = Package(
|
||||
/*
|
||||
* These defines are required on Wasm/WASI, to disable use of pthread.
|
||||
*/
|
||||
.define("OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED", .when(platforms: [Platform.wasi])),
|
||||
.define(
|
||||
"OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED",
|
||||
.when(platforms: [Platform.wasi])
|
||||
),
|
||||
.define("OPENSSL_NO_ASM", .when(platforms: [Platform.wasi])),
|
||||
]
|
||||
),
|
||||
.target(
|
||||
name: "CCryptoBoringSSLShims",
|
||||
dependencies: ["CCryptoBoringSSL"],
|
||||
exclude: [
|
||||
exclude: privacyManifestExclude + [
|
||||
"CMakeLists.txt"
|
||||
]
|
||||
],
|
||||
resources: privacyManifestResource
|
||||
),
|
||||
.target(
|
||||
name: "Crypto",
|
||||
dependencies: dependencies,
|
||||
exclude: [
|
||||
exclude: privacyManifestExclude + [
|
||||
"CMakeLists.txt",
|
||||
"AEADs/Nonces.swift.gyb",
|
||||
"Digests/Digests.swift.gyb",
|
||||
"Key Agreement/ECDH.swift.gyb",
|
||||
"Signatures/ECDSA.swift.gyb",
|
||||
],
|
||||
resources: privacyManifestResource,
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
@@ -126,32 +155,59 @@ let package = Package(
|
||||
"CCryptoBoringSSL",
|
||||
"CCryptoBoringSSLShims",
|
||||
"CryptoBoringWrapper",
|
||||
"Crypto"
|
||||
"Crypto",
|
||||
.product(name: "SwiftASN1", package: "swift-asn1"),
|
||||
],
|
||||
exclude: [
|
||||
"CMakeLists.txt",
|
||||
]
|
||||
exclude: privacyManifestExclude + [
|
||||
"CMakeLists.txt"
|
||||
],
|
||||
resources: privacyManifestResource,
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "CryptoBoringWrapper",
|
||||
dependencies: [
|
||||
"CCryptoBoringSSL",
|
||||
"CCryptoBoringSSLShims"
|
||||
"CCryptoBoringSSLShims",
|
||||
],
|
||||
exclude: [
|
||||
"CMakeLists.txt",
|
||||
]
|
||||
exclude: privacyManifestExclude + [
|
||||
"CMakeLists.txt"
|
||||
],
|
||||
resources: privacyManifestResource
|
||||
),
|
||||
.executableTarget(name: "crypto-shasum", dependencies: ["Crypto"]),
|
||||
.testTarget(
|
||||
name: "CryptoTests",
|
||||
dependencies: ["Crypto"],
|
||||
resources: [
|
||||
.copy("HPKE/hpke-test-vectors.json"),
|
||||
.copy("HPKE/hpke-test-vectors.json")
|
||||
],
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(name: "_CryptoExtrasTests", dependencies: ["_CryptoExtras"]),
|
||||
.testTarget(
|
||||
name: "_CryptoExtrasTests",
|
||||
dependencies: ["_CryptoExtras"],
|
||||
resources: [
|
||||
.copy("ECToolbox/H2CVectors/P256_XMD-SHA-256_SSWU_RO_.json"),
|
||||
.copy("ECToolbox/H2CVectors/P384_XMD-SHA-384_SSWU_RO_.json"),
|
||||
.copy("OPRFs/OPRFVectors/OPRFVectors-VOPRFDraft8.json"),
|
||||
.copy("OPRFs/OPRFVectors/OPRFVectors-VOPRFDraft19.json"),
|
||||
.copy("OPRFs/OPRFVectors/OPRFVectors-edgecases.json"),
|
||||
],
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(name: "CryptoBoringWrapperTests", dependencies: ["CryptoBoringWrapper"]),
|
||||
],
|
||||
cxxLanguageStandard: .cxx11
|
||||
cxxLanguageStandard: .cxx14
|
||||
)
|
||||
|
||||
// --- STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
|
||||
for target in package.targets {
|
||||
if target.type != .plugin {
|
||||
var settings = target.swiftSettings ?? []
|
||||
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
|
||||
settings.append(.enableUpcomingFeature("MemberImportVisibility"))
|
||||
target.swiftSettings = settings
|
||||
}
|
||||
}
|
||||
// --- END: STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
|
||||
@@ -7,9 +7,9 @@ Swift Crypto is an open-source implementation of a substantial portion of the AP
|
||||
Swift Crypto is available as a Swift Package Manager package. To use it, add the following dependency in your `Package.swift`:
|
||||
|
||||
```swift
|
||||
// swift-crypto 1.x and 2.x are almost API compatible, so most clients should
|
||||
// allow either
|
||||
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "3.0.0"),
|
||||
// swift-crypto 1.x, 2.x and 3.x are almost API compatible, so most clients
|
||||
// should allow any of them
|
||||
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "4.0.0"),
|
||||
```
|
||||
|
||||
and to your target, add `Crypto` to your dependencies. You can then `import Crypto` to get access to Swift Crypto's functionality.
|
||||
@@ -116,7 +116,9 @@ Swift Crypto | Minimum Swift Version
|
||||
`2.1.0 ..< 2.2.0` | 5.4
|
||||
`2.2.0 ..< 2.4.2` | 5.5
|
||||
`2.4.2 ..< 3.1.0` | 5.6
|
||||
`3.1.0 ...` | 5.7
|
||||
`3.1.0 ..< 3.3.0` | 5.7
|
||||
`3.3.0 ..< 3.8.0` | 5.8
|
||||
`3.8.0 ...` | 5.9
|
||||
|
||||
### Compatibility
|
||||
|
||||
@@ -136,5 +138,5 @@ To do so, please use the following dependency in your `Package.swift`:
|
||||
|
||||
### Developing Swift Crypto on macOS
|
||||
|
||||
Swift Crypto normally defers to the OS implementation of CryptoKit on macOS. Naturally, this makes developing Swift Crypto on macOS tricky. To get Swift Crypto to build the open source implementation on macOS, in `Package.swift`, uncomment the line that reads: `//.define("CRYPTO_IN_SWIFTPM_FORCE_BUILD_API")`, as this will force Swift Crypto to build its public API.
|
||||
Swift Crypto normally defers to the OS implementation of CryptoKit on macOS. Naturally, this makes developing Swift Crypto on macOS tricky. To get Swift Crypto to build the open source implementation on macOS, in `Package.swift`, change `let development = false` to `let development = true`, as this will force Swift Crypto to build its public API.
|
||||
|
||||
+310
-370
@@ -6,389 +6,329 @@
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
## See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
add_library(CCryptoBoringSSL STATIC
|
||||
"crypto/asn1/a_bitstr.c"
|
||||
"crypto/asn1/a_bool.c"
|
||||
"crypto/asn1/a_d2i_fp.c"
|
||||
"crypto/asn1/a_dup.c"
|
||||
"crypto/asn1/a_gentm.c"
|
||||
"crypto/asn1/a_i2d_fp.c"
|
||||
"crypto/asn1/a_int.c"
|
||||
"crypto/asn1/a_mbstr.c"
|
||||
"crypto/asn1/a_object.c"
|
||||
"crypto/asn1/a_octet.c"
|
||||
"crypto/asn1/a_strex.c"
|
||||
"crypto/asn1/a_strnid.c"
|
||||
"crypto/asn1/a_time.c"
|
||||
"crypto/asn1/a_type.c"
|
||||
"crypto/asn1/a_utctm.c"
|
||||
"crypto/asn1/asn1_lib.c"
|
||||
"crypto/asn1/asn1_par.c"
|
||||
"crypto/asn1/asn_pack.c"
|
||||
"crypto/asn1/f_int.c"
|
||||
"crypto/asn1/f_string.c"
|
||||
"crypto/asn1/posix_time.c"
|
||||
"crypto/asn1/tasn_dec.c"
|
||||
"crypto/asn1/tasn_enc.c"
|
||||
"crypto/asn1/tasn_fre.c"
|
||||
"crypto/asn1/tasn_new.c"
|
||||
"crypto/asn1/tasn_typ.c"
|
||||
"crypto/asn1/tasn_utl.c"
|
||||
"crypto/base64/base64.c"
|
||||
"crypto/bio/bio.c"
|
||||
"crypto/bio/bio_mem.c"
|
||||
"crypto/bio/connect.c"
|
||||
"crypto/bio/errno.c"
|
||||
"crypto/bio/fd.c"
|
||||
"crypto/bio/file.c"
|
||||
"crypto/bio/hexdump.c"
|
||||
"crypto/bio/pair.c"
|
||||
"crypto/bio/printf.c"
|
||||
"crypto/bio/socket.c"
|
||||
"crypto/bio/socket_helper.c"
|
||||
"crypto/blake2/blake2.c"
|
||||
"crypto/bn_extra/bn_asn1.c"
|
||||
"crypto/bn_extra/convert.c"
|
||||
"crypto/buf/buf.c"
|
||||
"crypto/bytestring/asn1_compat.c"
|
||||
"crypto/bytestring/ber.c"
|
||||
"crypto/bytestring/cbb.c"
|
||||
"crypto/bytestring/cbs.c"
|
||||
"crypto/bytestring/unicode.c"
|
||||
"crypto/chacha/chacha.c"
|
||||
"crypto/cipher_extra/cipher_extra.c"
|
||||
"crypto/cipher_extra/derive_key.c"
|
||||
"crypto/cipher_extra/e_aesctrhmac.c"
|
||||
"crypto/cipher_extra/e_aesgcmsiv.c"
|
||||
"crypto/cipher_extra/e_chacha20poly1305.c"
|
||||
"crypto/cipher_extra/e_des.c"
|
||||
"crypto/cipher_extra/e_null.c"
|
||||
"crypto/cipher_extra/e_rc2.c"
|
||||
"crypto/cipher_extra/e_rc4.c"
|
||||
"crypto/cipher_extra/e_tls.c"
|
||||
"crypto/cipher_extra/tls_cbc.c"
|
||||
"crypto/conf/conf.c"
|
||||
"crypto/cpu_aarch64_apple.c"
|
||||
"crypto/cpu_aarch64_fuchsia.c"
|
||||
"crypto/cpu_aarch64_linux.c"
|
||||
"crypto/cpu_aarch64_openbsd.c"
|
||||
"crypto/cpu_aarch64_sysreg.c"
|
||||
"crypto/cpu_aarch64_win.c"
|
||||
"crypto/cpu_arm.c"
|
||||
"crypto/cpu_arm_freebsd.c"
|
||||
"crypto/cpu_arm_linux.c"
|
||||
"crypto/cpu_intel.c"
|
||||
"crypto/crypto.c"
|
||||
"crypto/curve25519/curve25519.c"
|
||||
"crypto/curve25519/curve25519_64_adx.c"
|
||||
"crypto/curve25519/spake25519.c"
|
||||
"crypto/des/des.c"
|
||||
"crypto/dh_extra/dh_asn1.c"
|
||||
"crypto/dh_extra/params.c"
|
||||
"crypto/digest_extra/digest_extra.c"
|
||||
"crypto/dsa/dsa.c"
|
||||
"crypto/dsa/dsa_asn1.c"
|
||||
"crypto/ec_extra/ec_asn1.c"
|
||||
"crypto/ec_extra/ec_derive.c"
|
||||
"crypto/ec_extra/hash_to_curve.c"
|
||||
"crypto/ecdh_extra/ecdh_extra.c"
|
||||
"crypto/ecdsa_extra/ecdsa_asn1.c"
|
||||
"crypto/engine/engine.c"
|
||||
"crypto/err/err.c"
|
||||
"crypto/err/err_data.c"
|
||||
"crypto/evp/evp.c"
|
||||
"crypto/evp/evp_asn1.c"
|
||||
"crypto/evp/evp_ctx.c"
|
||||
"crypto/evp/p_dsa_asn1.c"
|
||||
"crypto/evp/p_ec.c"
|
||||
"crypto/evp/p_ec_asn1.c"
|
||||
"crypto/evp/p_ed25519.c"
|
||||
"crypto/evp/p_ed25519_asn1.c"
|
||||
"crypto/evp/p_hkdf.c"
|
||||
"crypto/evp/p_rsa.c"
|
||||
"crypto/evp/p_rsa_asn1.c"
|
||||
"crypto/evp/p_x25519.c"
|
||||
"crypto/evp/p_x25519_asn1.c"
|
||||
"crypto/evp/pbkdf.c"
|
||||
"crypto/evp/print.c"
|
||||
"crypto/evp/scrypt.c"
|
||||
"crypto/evp/sign.c"
|
||||
"crypto/ex_data.c"
|
||||
"crypto/fipsmodule/aes/aes.c"
|
||||
"crypto/fipsmodule/aes/aes_nohw.c"
|
||||
"crypto/fipsmodule/aes/key_wrap.c"
|
||||
"crypto/fipsmodule/aes/mode_wrappers.c"
|
||||
"crypto/fipsmodule/bn/add.c"
|
||||
"crypto/fipsmodule/bn/asm/x86_64-gcc.c"
|
||||
"crypto/fipsmodule/bn/bn.c"
|
||||
"crypto/fipsmodule/bn/bytes.c"
|
||||
"crypto/fipsmodule/bn/cmp.c"
|
||||
"crypto/fipsmodule/bn/ctx.c"
|
||||
"crypto/fipsmodule/bn/div.c"
|
||||
"crypto/fipsmodule/bn/div_extra.c"
|
||||
"crypto/fipsmodule/bn/exponentiation.c"
|
||||
"crypto/fipsmodule/bn/gcd.c"
|
||||
"crypto/fipsmodule/bn/gcd_extra.c"
|
||||
"crypto/fipsmodule/bn/generic.c"
|
||||
"crypto/fipsmodule/bn/jacobi.c"
|
||||
"crypto/fipsmodule/bn/montgomery.c"
|
||||
"crypto/fipsmodule/bn/montgomery_inv.c"
|
||||
"crypto/fipsmodule/bn/mul.c"
|
||||
"crypto/fipsmodule/bn/prime.c"
|
||||
"crypto/fipsmodule/bn/random.c"
|
||||
"crypto/fipsmodule/bn/rsaz_exp.c"
|
||||
"crypto/fipsmodule/bn/shift.c"
|
||||
"crypto/fipsmodule/bn/sqrt.c"
|
||||
"crypto/fipsmodule/cipher/aead.c"
|
||||
"crypto/fipsmodule/cipher/cipher.c"
|
||||
"crypto/fipsmodule/cipher/e_aes.c"
|
||||
"crypto/fipsmodule/cipher/e_aesccm.c"
|
||||
"crypto/fipsmodule/cmac/cmac.c"
|
||||
"crypto/fipsmodule/dh/check.c"
|
||||
"crypto/fipsmodule/dh/dh.c"
|
||||
"crypto/fipsmodule/digest/digest.c"
|
||||
"crypto/fipsmodule/digest/digests.c"
|
||||
"crypto/fipsmodule/digestsign/digestsign.c"
|
||||
"crypto/fipsmodule/ec/ec.c"
|
||||
"crypto/fipsmodule/ec/ec_key.c"
|
||||
"crypto/fipsmodule/ec/ec_montgomery.c"
|
||||
"crypto/fipsmodule/ec/felem.c"
|
||||
"crypto/fipsmodule/ec/oct.c"
|
||||
"crypto/fipsmodule/ec/p224-64.c"
|
||||
"crypto/fipsmodule/ec/p256-nistz.c"
|
||||
"crypto/fipsmodule/ec/p256.c"
|
||||
"crypto/fipsmodule/ec/scalar.c"
|
||||
"crypto/fipsmodule/ec/simple.c"
|
||||
"crypto/fipsmodule/ec/simple_mul.c"
|
||||
"crypto/fipsmodule/ec/util.c"
|
||||
"crypto/fipsmodule/ec/wnaf.c"
|
||||
"crypto/fipsmodule/ecdh/ecdh.c"
|
||||
"crypto/fipsmodule/ecdsa/ecdsa.c"
|
||||
"crypto/fipsmodule/fips_shared_support.c"
|
||||
"crypto/fipsmodule/hkdf/hkdf.c"
|
||||
"crypto/fipsmodule/hmac/hmac.c"
|
||||
"crypto/fipsmodule/md4/md4.c"
|
||||
"crypto/fipsmodule/md5/md5.c"
|
||||
"crypto/fipsmodule/modes/cbc.c"
|
||||
"crypto/fipsmodule/modes/cfb.c"
|
||||
"crypto/fipsmodule/modes/ctr.c"
|
||||
"crypto/fipsmodule/modes/gcm.c"
|
||||
"crypto/fipsmodule/modes/gcm_nohw.c"
|
||||
"crypto/fipsmodule/modes/ofb.c"
|
||||
"crypto/fipsmodule/modes/polyval.c"
|
||||
"crypto/fipsmodule/rand/ctrdrbg.c"
|
||||
"crypto/fipsmodule/rand/fork_detect.c"
|
||||
"crypto/fipsmodule/rand/rand.c"
|
||||
"crypto/fipsmodule/rand/urandom.c"
|
||||
"crypto/fipsmodule/rsa/blinding.c"
|
||||
"crypto/fipsmodule/rsa/padding.c"
|
||||
"crypto/fipsmodule/rsa/rsa.c"
|
||||
"crypto/fipsmodule/rsa/rsa_impl.c"
|
||||
"crypto/fipsmodule/self_check/fips.c"
|
||||
"crypto/fipsmodule/self_check/self_check.c"
|
||||
"crypto/fipsmodule/service_indicator/service_indicator.c"
|
||||
"crypto/fipsmodule/sha/sha1.c"
|
||||
"crypto/fipsmodule/sha/sha256.c"
|
||||
"crypto/fipsmodule/sha/sha512.c"
|
||||
"crypto/fipsmodule/tls/kdf.c"
|
||||
"crypto/hpke/hpke.c"
|
||||
"crypto/hrss/hrss.c"
|
||||
"crypto/kyber/keccak.c"
|
||||
"crypto/kyber/kyber.c"
|
||||
"crypto/lhash/lhash.c"
|
||||
"crypto/mem.c"
|
||||
"crypto/obj/obj.c"
|
||||
"crypto/obj/obj_xref.c"
|
||||
"crypto/pem/pem_all.c"
|
||||
"crypto/pem/pem_info.c"
|
||||
"crypto/pem/pem_lib.c"
|
||||
"crypto/pem/pem_oth.c"
|
||||
"crypto/pem/pem_pk8.c"
|
||||
"crypto/pem/pem_pkey.c"
|
||||
"crypto/pem/pem_x509.c"
|
||||
"crypto/pem/pem_xaux.c"
|
||||
"crypto/pkcs7/pkcs7.c"
|
||||
"crypto/pkcs7/pkcs7_x509.c"
|
||||
"crypto/pkcs8/p5_pbev2.c"
|
||||
"crypto/pkcs8/pkcs8.c"
|
||||
"crypto/pkcs8/pkcs8_x509.c"
|
||||
"crypto/poly1305/poly1305.c"
|
||||
"crypto/poly1305/poly1305_arm.c"
|
||||
"crypto/poly1305/poly1305_vec.c"
|
||||
"crypto/pool/pool.c"
|
||||
"crypto/rand_extra/deterministic.c"
|
||||
"crypto/rand_extra/forkunsafe.c"
|
||||
"crypto/rand_extra/getentropy.c"
|
||||
"crypto/rand_extra/ios.c"
|
||||
"crypto/rand_extra/passive.c"
|
||||
"crypto/rand_extra/rand_extra.c"
|
||||
"crypto/rand_extra/trusty.c"
|
||||
"crypto/rand_extra/windows.c"
|
||||
"crypto/rc4/rc4.c"
|
||||
"crypto/refcount.c"
|
||||
"crypto/rsa_extra/rsa_asn1.c"
|
||||
"crypto/rsa_extra/rsa_crypt.c"
|
||||
"crypto/rsa_extra/rsa_print.c"
|
||||
"crypto/siphash/siphash.c"
|
||||
"crypto/stack/stack.c"
|
||||
"crypto/thread.c"
|
||||
"crypto/thread_none.c"
|
||||
"crypto/thread_pthread.c"
|
||||
"crypto/thread_win.c"
|
||||
"crypto/trust_token/pmbtoken.c"
|
||||
"crypto/trust_token/trust_token.c"
|
||||
"crypto/trust_token/voprf.c"
|
||||
"crypto/x509/a_digest.c"
|
||||
"crypto/x509/a_sign.c"
|
||||
"crypto/x509/a_verify.c"
|
||||
"crypto/x509/algorithm.c"
|
||||
"crypto/x509/asn1_gen.c"
|
||||
"crypto/x509/by_dir.c"
|
||||
"crypto/x509/by_file.c"
|
||||
"crypto/x509/i2d_pr.c"
|
||||
"crypto/x509/name_print.c"
|
||||
"crypto/x509/policy.c"
|
||||
"crypto/x509/rsa_pss.c"
|
||||
"crypto/x509/t_crl.c"
|
||||
"crypto/x509/t_req.c"
|
||||
"crypto/x509/t_x509.c"
|
||||
"crypto/x509/t_x509a.c"
|
||||
"crypto/x509/x509.c"
|
||||
"crypto/x509/x509_att.c"
|
||||
"crypto/x509/x509_cmp.c"
|
||||
"crypto/x509/x509_d2.c"
|
||||
"crypto/x509/x509_def.c"
|
||||
"crypto/x509/x509_ext.c"
|
||||
"crypto/x509/x509_lu.c"
|
||||
"crypto/x509/x509_obj.c"
|
||||
"crypto/x509/x509_req.c"
|
||||
"crypto/x509/x509_set.c"
|
||||
"crypto/x509/x509_trs.c"
|
||||
"crypto/x509/x509_txt.c"
|
||||
"crypto/x509/x509_v3.c"
|
||||
"crypto/x509/x509_vfy.c"
|
||||
"crypto/x509/x509_vpm.c"
|
||||
"crypto/x509/x509cset.c"
|
||||
"crypto/x509/x509name.c"
|
||||
"crypto/x509/x509rset.c"
|
||||
"crypto/x509/x509spki.c"
|
||||
"crypto/x509/x_algor.c"
|
||||
"crypto/x509/x_all.c"
|
||||
"crypto/x509/x_attrib.c"
|
||||
"crypto/x509/x_crl.c"
|
||||
"crypto/x509/x_exten.c"
|
||||
"crypto/x509/x_info.c"
|
||||
"crypto/x509/x_name.c"
|
||||
"crypto/x509/x_pkey.c"
|
||||
"crypto/x509/x_pubkey.c"
|
||||
"crypto/x509/x_req.c"
|
||||
"crypto/x509/x_sig.c"
|
||||
"crypto/x509/x_spki.c"
|
||||
"crypto/x509/x_val.c"
|
||||
"crypto/x509/x_x509.c"
|
||||
"crypto/x509/x_x509a.c"
|
||||
"crypto/x509v3/v3_akey.c"
|
||||
"crypto/x509v3/v3_akeya.c"
|
||||
"crypto/x509v3/v3_alt.c"
|
||||
"crypto/x509v3/v3_bcons.c"
|
||||
"crypto/x509v3/v3_bitst.c"
|
||||
"crypto/x509v3/v3_conf.c"
|
||||
"crypto/x509v3/v3_cpols.c"
|
||||
"crypto/x509v3/v3_crld.c"
|
||||
"crypto/x509v3/v3_enum.c"
|
||||
"crypto/x509v3/v3_extku.c"
|
||||
"crypto/x509v3/v3_genn.c"
|
||||
"crypto/x509v3/v3_ia5.c"
|
||||
"crypto/x509v3/v3_info.c"
|
||||
"crypto/x509v3/v3_int.c"
|
||||
"crypto/x509v3/v3_lib.c"
|
||||
"crypto/x509v3/v3_ncons.c"
|
||||
"crypto/x509v3/v3_ocsp.c"
|
||||
"crypto/x509v3/v3_pcons.c"
|
||||
"crypto/x509v3/v3_pmaps.c"
|
||||
"crypto/x509v3/v3_prn.c"
|
||||
"crypto/x509v3/v3_purp.c"
|
||||
"crypto/x509v3/v3_skey.c"
|
||||
"crypto/x509v3/v3_utl.c")
|
||||
"crypto/asn1/a_bitstr.cc"
|
||||
"crypto/asn1/a_bool.cc"
|
||||
"crypto/asn1/a_d2i_fp.cc"
|
||||
"crypto/asn1/a_dup.cc"
|
||||
"crypto/asn1/a_gentm.cc"
|
||||
"crypto/asn1/a_i2d_fp.cc"
|
||||
"crypto/asn1/a_int.cc"
|
||||
"crypto/asn1/a_mbstr.cc"
|
||||
"crypto/asn1/a_object.cc"
|
||||
"crypto/asn1/a_octet.cc"
|
||||
"crypto/asn1/a_strex.cc"
|
||||
"crypto/asn1/a_strnid.cc"
|
||||
"crypto/asn1/a_time.cc"
|
||||
"crypto/asn1/a_type.cc"
|
||||
"crypto/asn1/a_utctm.cc"
|
||||
"crypto/asn1/asn1_lib.cc"
|
||||
"crypto/asn1/asn1_par.cc"
|
||||
"crypto/asn1/asn_pack.cc"
|
||||
"crypto/asn1/f_int.cc"
|
||||
"crypto/asn1/f_string.cc"
|
||||
"crypto/asn1/posix_time.cc"
|
||||
"crypto/asn1/tasn_dec.cc"
|
||||
"crypto/asn1/tasn_enc.cc"
|
||||
"crypto/asn1/tasn_fre.cc"
|
||||
"crypto/asn1/tasn_new.cc"
|
||||
"crypto/asn1/tasn_typ.cc"
|
||||
"crypto/asn1/tasn_utl.cc"
|
||||
"crypto/base64/base64.cc"
|
||||
"crypto/bio/bio.cc"
|
||||
"crypto/bio/bio_mem.cc"
|
||||
"crypto/bio/connect.cc"
|
||||
"crypto/bio/errno.cc"
|
||||
"crypto/bio/fd.cc"
|
||||
"crypto/bio/file.cc"
|
||||
"crypto/bio/hexdump.cc"
|
||||
"crypto/bio/pair.cc"
|
||||
"crypto/bio/printf.cc"
|
||||
"crypto/bio/socket.cc"
|
||||
"crypto/bio/socket_helper.cc"
|
||||
"crypto/blake2/blake2.cc"
|
||||
"crypto/bn_extra/bn_asn1.cc"
|
||||
"crypto/bn_extra/convert.cc"
|
||||
"crypto/buf/buf.cc"
|
||||
"crypto/bytestring/asn1_compat.cc"
|
||||
"crypto/bytestring/ber.cc"
|
||||
"crypto/bytestring/cbb.cc"
|
||||
"crypto/bytestring/cbs.cc"
|
||||
"crypto/bytestring/unicode.cc"
|
||||
"crypto/chacha/chacha.cc"
|
||||
"crypto/cipher_extra/cipher_extra.cc"
|
||||
"crypto/cipher_extra/derive_key.cc"
|
||||
"crypto/cipher_extra/e_aesctrhmac.cc"
|
||||
"crypto/cipher_extra/e_aesgcmsiv.cc"
|
||||
"crypto/cipher_extra/e_chacha20poly1305.cc"
|
||||
"crypto/cipher_extra/e_des.cc"
|
||||
"crypto/cipher_extra/e_null.cc"
|
||||
"crypto/cipher_extra/e_rc2.cc"
|
||||
"crypto/cipher_extra/e_rc4.cc"
|
||||
"crypto/cipher_extra/e_tls.cc"
|
||||
"crypto/cipher_extra/tls_cbc.cc"
|
||||
"crypto/conf/conf.cc"
|
||||
"crypto/cpu_aarch64_apple.cc"
|
||||
"crypto/cpu_aarch64_fuchsia.cc"
|
||||
"crypto/cpu_aarch64_linux.cc"
|
||||
"crypto/cpu_aarch64_openbsd.cc"
|
||||
"crypto/cpu_aarch64_sysreg.cc"
|
||||
"crypto/cpu_aarch64_win.cc"
|
||||
"crypto/cpu_arm_freebsd.cc"
|
||||
"crypto/cpu_arm_linux.cc"
|
||||
"crypto/cpu_intel.cc"
|
||||
"crypto/crypto.cc"
|
||||
"crypto/curve25519/curve25519.cc"
|
||||
"crypto/curve25519/curve25519_64_adx.cc"
|
||||
"crypto/curve25519/spake25519.cc"
|
||||
"crypto/des/des.cc"
|
||||
"crypto/dh_extra/dh_asn1.cc"
|
||||
"crypto/dh_extra/params.cc"
|
||||
"crypto/digest_extra/digest_extra.cc"
|
||||
"crypto/dsa/dsa.cc"
|
||||
"crypto/dsa/dsa_asn1.cc"
|
||||
"crypto/ec_extra/ec_asn1.cc"
|
||||
"crypto/ec_extra/ec_derive.cc"
|
||||
"crypto/ec_extra/hash_to_curve.cc"
|
||||
"crypto/ecdh_extra/ecdh_extra.cc"
|
||||
"crypto/ecdsa_extra/ecdsa_asn1.cc"
|
||||
"crypto/engine/engine.cc"
|
||||
"crypto/err/err.cc"
|
||||
"crypto/evp/evp.cc"
|
||||
"crypto/evp/evp_asn1.cc"
|
||||
"crypto/evp/evp_ctx.cc"
|
||||
"crypto/evp/p_dh.cc"
|
||||
"crypto/evp/p_dh_asn1.cc"
|
||||
"crypto/evp/p_dsa_asn1.cc"
|
||||
"crypto/evp/p_ec.cc"
|
||||
"crypto/evp/p_ec_asn1.cc"
|
||||
"crypto/evp/p_ed25519.cc"
|
||||
"crypto/evp/p_ed25519_asn1.cc"
|
||||
"crypto/evp/p_hkdf.cc"
|
||||
"crypto/evp/p_rsa.cc"
|
||||
"crypto/evp/p_rsa_asn1.cc"
|
||||
"crypto/evp/p_x25519.cc"
|
||||
"crypto/evp/p_x25519_asn1.cc"
|
||||
"crypto/evp/pbkdf.cc"
|
||||
"crypto/evp/print.cc"
|
||||
"crypto/evp/scrypt.cc"
|
||||
"crypto/evp/sign.cc"
|
||||
"crypto/ex_data.cc"
|
||||
"crypto/fipsmodule/bcm.cc"
|
||||
"crypto/fipsmodule/fips_shared_support.cc"
|
||||
"crypto/hpke/hpke.cc"
|
||||
"crypto/hrss/hrss.cc"
|
||||
"crypto/kyber/kyber.cc"
|
||||
"crypto/lhash/lhash.cc"
|
||||
"crypto/md4/md4.cc"
|
||||
"crypto/md5/md5.cc"
|
||||
"crypto/mem.cc"
|
||||
"crypto/mldsa/mldsa.cc"
|
||||
"crypto/mlkem/mlkem.cc"
|
||||
"crypto/obj/obj.cc"
|
||||
"crypto/obj/obj_xref.cc"
|
||||
"crypto/pem/pem_all.cc"
|
||||
"crypto/pem/pem_info.cc"
|
||||
"crypto/pem/pem_lib.cc"
|
||||
"crypto/pem/pem_oth.cc"
|
||||
"crypto/pem/pem_pk8.cc"
|
||||
"crypto/pem/pem_pkey.cc"
|
||||
"crypto/pem/pem_x509.cc"
|
||||
"crypto/pem/pem_xaux.cc"
|
||||
"crypto/pkcs7/pkcs7.cc"
|
||||
"crypto/pkcs7/pkcs7_x509.cc"
|
||||
"crypto/pkcs8/p5_pbev2.cc"
|
||||
"crypto/pkcs8/pkcs8.cc"
|
||||
"crypto/pkcs8/pkcs8_x509.cc"
|
||||
"crypto/poly1305/poly1305.cc"
|
||||
"crypto/poly1305/poly1305_arm.cc"
|
||||
"crypto/poly1305/poly1305_vec.cc"
|
||||
"crypto/pool/pool.cc"
|
||||
"crypto/rand_extra/deterministic.cc"
|
||||
"crypto/rand_extra/fork_detect.cc"
|
||||
"crypto/rand_extra/forkunsafe.cc"
|
||||
"crypto/rand_extra/getentropy.cc"
|
||||
"crypto/rand_extra/ios.cc"
|
||||
"crypto/rand_extra/passive.cc"
|
||||
"crypto/rand_extra/rand_extra.cc"
|
||||
"crypto/rand_extra/trusty.cc"
|
||||
"crypto/rand_extra/urandom.cc"
|
||||
"crypto/rand_extra/windows.cc"
|
||||
"crypto/rc4/rc4.cc"
|
||||
"crypto/refcount.cc"
|
||||
"crypto/rsa_extra/rsa_asn1.cc"
|
||||
"crypto/rsa_extra/rsa_crypt.cc"
|
||||
"crypto/rsa_extra/rsa_extra.cc"
|
||||
"crypto/rsa_extra/rsa_print.cc"
|
||||
"crypto/sha/sha1.cc"
|
||||
"crypto/sha/sha256.cc"
|
||||
"crypto/sha/sha512.cc"
|
||||
"crypto/siphash/siphash.cc"
|
||||
"crypto/slhdsa/fors.cc"
|
||||
"crypto/slhdsa/merkle.cc"
|
||||
"crypto/slhdsa/slhdsa.cc"
|
||||
"crypto/slhdsa/thash.cc"
|
||||
"crypto/slhdsa/wots.cc"
|
||||
"crypto/stack/stack.cc"
|
||||
"crypto/thread.cc"
|
||||
"crypto/thread_none.cc"
|
||||
"crypto/thread_pthread.cc"
|
||||
"crypto/thread_win.cc"
|
||||
"crypto/trust_token/pmbtoken.cc"
|
||||
"crypto/trust_token/trust_token.cc"
|
||||
"crypto/trust_token/voprf.cc"
|
||||
"crypto/x509/a_digest.cc"
|
||||
"crypto/x509/a_sign.cc"
|
||||
"crypto/x509/a_verify.cc"
|
||||
"crypto/x509/algorithm.cc"
|
||||
"crypto/x509/asn1_gen.cc"
|
||||
"crypto/x509/by_dir.cc"
|
||||
"crypto/x509/by_file.cc"
|
||||
"crypto/x509/i2d_pr.cc"
|
||||
"crypto/x509/name_print.cc"
|
||||
"crypto/x509/policy.cc"
|
||||
"crypto/x509/rsa_pss.cc"
|
||||
"crypto/x509/t_crl.cc"
|
||||
"crypto/x509/t_req.cc"
|
||||
"crypto/x509/t_x509.cc"
|
||||
"crypto/x509/t_x509a.cc"
|
||||
"crypto/x509/v3_akey.cc"
|
||||
"crypto/x509/v3_akeya.cc"
|
||||
"crypto/x509/v3_alt.cc"
|
||||
"crypto/x509/v3_bcons.cc"
|
||||
"crypto/x509/v3_bitst.cc"
|
||||
"crypto/x509/v3_conf.cc"
|
||||
"crypto/x509/v3_cpols.cc"
|
||||
"crypto/x509/v3_crld.cc"
|
||||
"crypto/x509/v3_enum.cc"
|
||||
"crypto/x509/v3_extku.cc"
|
||||
"crypto/x509/v3_genn.cc"
|
||||
"crypto/x509/v3_ia5.cc"
|
||||
"crypto/x509/v3_info.cc"
|
||||
"crypto/x509/v3_int.cc"
|
||||
"crypto/x509/v3_lib.cc"
|
||||
"crypto/x509/v3_ncons.cc"
|
||||
"crypto/x509/v3_ocsp.cc"
|
||||
"crypto/x509/v3_pcons.cc"
|
||||
"crypto/x509/v3_pmaps.cc"
|
||||
"crypto/x509/v3_prn.cc"
|
||||
"crypto/x509/v3_purp.cc"
|
||||
"crypto/x509/v3_skey.cc"
|
||||
"crypto/x509/v3_utl.cc"
|
||||
"crypto/x509/x509.cc"
|
||||
"crypto/x509/x509_att.cc"
|
||||
"crypto/x509/x509_cmp.cc"
|
||||
"crypto/x509/x509_d2.cc"
|
||||
"crypto/x509/x509_def.cc"
|
||||
"crypto/x509/x509_ext.cc"
|
||||
"crypto/x509/x509_lu.cc"
|
||||
"crypto/x509/x509_obj.cc"
|
||||
"crypto/x509/x509_req.cc"
|
||||
"crypto/x509/x509_set.cc"
|
||||
"crypto/x509/x509_trs.cc"
|
||||
"crypto/x509/x509_txt.cc"
|
||||
"crypto/x509/x509_v3.cc"
|
||||
"crypto/x509/x509_vfy.cc"
|
||||
"crypto/x509/x509_vpm.cc"
|
||||
"crypto/x509/x509cset.cc"
|
||||
"crypto/x509/x509name.cc"
|
||||
"crypto/x509/x509rset.cc"
|
||||
"crypto/x509/x509spki.cc"
|
||||
"crypto/x509/x_algor.cc"
|
||||
"crypto/x509/x_all.cc"
|
||||
"crypto/x509/x_attrib.cc"
|
||||
"crypto/x509/x_crl.cc"
|
||||
"crypto/x509/x_exten.cc"
|
||||
"crypto/x509/x_name.cc"
|
||||
"crypto/x509/x_pubkey.cc"
|
||||
"crypto/x509/x_req.cc"
|
||||
"crypto/x509/x_sig.cc"
|
||||
"crypto/x509/x_spki.cc"
|
||||
"crypto/x509/x_val.cc"
|
||||
"crypto/x509/x_x509.cc"
|
||||
"crypto/x509/x_x509a.cc"
|
||||
"gen/crypto/err_data.cc")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Darwin AND CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
|
||||
target_sources(CCryptoBoringSSL PRIVATE
|
||||
crypto/chacha/chacha-x86_64-mac.mac.x86_64.S
|
||||
crypto/cipher_extra/aes128gcmsiv-x86_64-mac.mac.x86_64.S
|
||||
crypto/cipher_extra/chacha20_poly1305_x86_64-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/aesni-gcm-x86_64-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/aesni-x86_64-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/ghash-ssse3-x86_64-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/ghash-x86_64-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/md5-x86_64-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/p256-x86_64-asm-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/p256_beeu-x86_64-asm-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/rdrand-x86_64-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/rsaz-avx2-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/sha1-x86_64-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/sha256-x86_64-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/sha512-x86_64-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/vpaes-x86_64-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/x86_64-mont-mac.mac.x86_64.S
|
||||
crypto/fipsmodule/x86_64-mont5-mac.mac.x86_64.S)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|Android" AND CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
|
||||
gen/bcm/aes-gcm-avx10-x86_64-apple.S
|
||||
gen/bcm/aesni-gcm-x86_64-apple.S
|
||||
gen/bcm/aesni-x86_64-apple.S
|
||||
gen/bcm/ghash-ssse3-x86_64-apple.S
|
||||
gen/bcm/ghash-x86_64-apple.S
|
||||
gen/bcm/p256-x86_64-asm-apple.S
|
||||
gen/bcm/p256_beeu-x86_64-asm-apple.S
|
||||
gen/bcm/rdrand-x86_64-apple.S
|
||||
gen/bcm/rsaz-avx2-apple.S
|
||||
gen/bcm/sha1-x86_64-apple.S
|
||||
gen/bcm/sha256-x86_64-apple.S
|
||||
gen/bcm/sha512-x86_64-apple.S
|
||||
gen/bcm/vpaes-x86_64-apple.S
|
||||
gen/bcm/x86_64-mont-apple.S
|
||||
gen/bcm/x86_64-mont5-apple.S
|
||||
gen/crypto/aes128gcmsiv-x86_64-apple.S
|
||||
gen/crypto/chacha-x86_64-apple.S
|
||||
gen/crypto/chacha20_poly1305_x86_64-apple.S
|
||||
gen/crypto/md5-x86_64-apple.S)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD" AND CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
|
||||
target_sources(CCryptoBoringSSL PRIVATE
|
||||
crypto/chacha/chacha-x86_64-linux.linux.x86_64.S
|
||||
crypto/cipher_extra/aes128gcmsiv-x86_64-linux.linux.x86_64.S
|
||||
crypto/cipher_extra/chacha20_poly1305_x86_64-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/aesni-gcm-x86_64-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/aesni-x86_64-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/ghash-ssse3-x86_64-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/ghash-x86_64-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/md5-x86_64-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/p256-x86_64-asm-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/p256_beeu-x86_64-asm-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/rdrand-x86_64-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/rsaz-avx2-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/sha1-x86_64-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/sha256-x86_64-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/sha512-x86_64-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/vpaes-x86_64-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/x86_64-mont-linux.linux.x86_64.S
|
||||
crypto/fipsmodule/x86_64-mont5-linux.linux.x86_64.S)
|
||||
gen/bcm/aes-gcm-avx10-x86_64-linux.S
|
||||
gen/bcm/aesni-gcm-x86_64-linux.S
|
||||
gen/bcm/aesni-x86_64-linux.S
|
||||
gen/bcm/ghash-ssse3-x86_64-linux.S
|
||||
gen/bcm/ghash-x86_64-linux.S
|
||||
gen/bcm/p256-x86_64-asm-linux.S
|
||||
gen/bcm/p256_beeu-x86_64-asm-linux.S
|
||||
gen/bcm/rdrand-x86_64-linux.S
|
||||
gen/bcm/rsaz-avx2-linux.S
|
||||
gen/bcm/sha1-x86_64-linux.S
|
||||
gen/bcm/sha256-x86_64-linux.S
|
||||
gen/bcm/sha512-x86_64-linux.S
|
||||
gen/bcm/vpaes-x86_64-linux.S
|
||||
gen/bcm/x86_64-mont-linux.S
|
||||
gen/bcm/x86_64-mont5-linux.S
|
||||
gen/crypto/aes128gcmsiv-x86_64-linux.S
|
||||
gen/crypto/chacha-x86_64-linux.S
|
||||
gen/crypto/chacha20_poly1305_x86_64-linux.S
|
||||
gen/crypto/md5-x86_64-linux.S)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
||||
target_sources(CCryptoBoringSSL PRIVATE
|
||||
crypto/chacha/chacha-armv8-ios.ios.aarch64.S
|
||||
crypto/cipher_extra/chacha20_poly1305_armv8-ios.ios.aarch64.S
|
||||
crypto/fipsmodule/aesv8-armv8-ios.ios.aarch64.S
|
||||
crypto/fipsmodule/aesv8-gcm-armv8-ios.ios.aarch64.S
|
||||
crypto/fipsmodule/armv8-mont-ios.ios.aarch64.S
|
||||
crypto/fipsmodule/bn-armv8-ios.ios.aarch64.S
|
||||
crypto/fipsmodule/ghash-neon-armv8-ios.ios.aarch64.S
|
||||
crypto/fipsmodule/ghashv8-armv8-ios.ios.aarch64.S
|
||||
crypto/fipsmodule/p256-armv8-asm-ios.ios.aarch64.S
|
||||
crypto/fipsmodule/p256_beeu-armv8-asm-ios.ios.aarch64.S
|
||||
crypto/fipsmodule/sha1-armv8-ios.ios.aarch64.S
|
||||
crypto/fipsmodule/sha256-armv8-ios.ios.aarch64.S
|
||||
crypto/fipsmodule/sha512-armv8-ios.ios.aarch64.S
|
||||
crypto/fipsmodule/vpaes-armv8-ios.ios.aarch64.S)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|Android" AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
||||
gen/bcm/aesv8-armv8-apple.S
|
||||
gen/bcm/aesv8-gcm-armv8-apple.S
|
||||
gen/bcm/armv8-mont-apple.S
|
||||
gen/bcm/bn-armv8-apple.S
|
||||
gen/bcm/ghash-neon-armv8-apple.S
|
||||
gen/bcm/ghashv8-armv8-apple.S
|
||||
gen/bcm/p256-armv8-asm-apple.S
|
||||
gen/bcm/p256_beeu-armv8-asm-apple.S
|
||||
gen/bcm/sha1-armv8-apple.S
|
||||
gen/bcm/sha256-armv8-apple.S
|
||||
gen/bcm/sha512-armv8-apple.S
|
||||
gen/bcm/vpaes-armv8-apple.S
|
||||
gen/crypto/chacha-armv8-apple.S
|
||||
gen/crypto/chacha20_poly1305_armv8-apple.S)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD" AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
||||
target_sources(CCryptoBoringSSL PRIVATE
|
||||
crypto/chacha/chacha-armv8-linux.linux.aarch64.S
|
||||
crypto/cipher_extra/chacha20_poly1305_armv8-linux.linux.aarch64.S
|
||||
crypto/fipsmodule/aesv8-armv8-linux.linux.aarch64.S
|
||||
crypto/fipsmodule/aesv8-gcm-armv8-linux.linux.aarch64.S
|
||||
crypto/fipsmodule/armv8-mont-linux.linux.aarch64.S
|
||||
crypto/fipsmodule/bn-armv8-linux.linux.aarch64.S
|
||||
crypto/fipsmodule/ghash-neon-armv8-linux.linux.aarch64.S
|
||||
crypto/fipsmodule/ghashv8-armv8-linux.linux.aarch64.S
|
||||
crypto/fipsmodule/p256-armv8-asm-linux.linux.aarch64.S
|
||||
crypto/fipsmodule/p256_beeu-armv8-asm-linux.linux.aarch64.S
|
||||
crypto/fipsmodule/sha1-armv8-linux.linux.aarch64.S
|
||||
crypto/fipsmodule/sha256-armv8-linux.linux.aarch64.S
|
||||
crypto/fipsmodule/sha512-armv8-linux.linux.aarch64.S
|
||||
crypto/fipsmodule/vpaes-armv8-linux.linux.aarch64.S)
|
||||
gen/bcm/aesv8-armv8-linux.S
|
||||
gen/bcm/aesv8-gcm-armv8-linux.S
|
||||
gen/bcm/armv8-mont-linux.S
|
||||
gen/bcm/bn-armv8-linux.S
|
||||
gen/bcm/ghash-neon-armv8-linux.S
|
||||
gen/bcm/ghashv8-armv8-linux.S
|
||||
gen/bcm/p256-armv8-asm-linux.S
|
||||
gen/bcm/p256_beeu-armv8-asm-linux.S
|
||||
gen/bcm/sha1-armv8-linux.S
|
||||
gen/bcm/sha256-armv8-linux.S
|
||||
gen/bcm/sha512-armv8-linux.S
|
||||
gen/bcm/vpaes-armv8-linux.S
|
||||
gen/crypto/chacha-armv8-linux.S
|
||||
gen/crypto/chacha20_poly1305_armv8-linux.S)
|
||||
endif()
|
||||
|
||||
target_include_directories(CCryptoBoringSSL PUBLIC
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrivacyTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyCollectedDataTypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyTrackingDomains</key>
|
||||
<array/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
+3
-2
@@ -142,6 +142,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
|
||||
const unsigned char *p;
|
||||
unsigned char *s;
|
||||
int padding;
|
||||
uint8_t padding_mask;
|
||||
|
||||
if (len < 1) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_SHORT);
|
||||
@@ -170,7 +171,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
|
||||
}
|
||||
|
||||
// Unused bits in a BIT STRING must be zero.
|
||||
uint8_t padding_mask = (1 << padding) - 1;
|
||||
padding_mask = (1 << padding) - 1;
|
||||
if (padding != 0 && (len < 1 || (p[len - 1] & padding_mask) != 0)) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BIT_STRING_PADDING);
|
||||
goto err;
|
||||
@@ -182,7 +183,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
|
||||
ret->flags |= (ASN1_STRING_FLAG_BITS_LEFT | padding); // set
|
||||
|
||||
if (len > 0) {
|
||||
s = OPENSSL_memdup(p, len);
|
||||
s = reinterpret_cast<uint8_t *>(OPENSSL_memdup(p, len));
|
||||
if (s == NULL) {
|
||||
goto err;
|
||||
}
|
||||
File renamed without changes.
+1
-1
@@ -72,7 +72,7 @@ void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x) {
|
||||
return NULL;
|
||||
}
|
||||
const uint8_t *ptr = data;
|
||||
void *ret = ASN1_item_d2i(x, &ptr, len, it);
|
||||
void *ret = ASN1_item_d2i(reinterpret_cast<ASN1_VALUE **>(x), &ptr, len, it);
|
||||
OPENSSL_free(data);
|
||||
return ret;
|
||||
}
|
||||
+1
-1
@@ -73,7 +73,7 @@ void *ASN1_item_dup(const ASN1_ITEM *it, void *x) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
i = ASN1_item_i2d(x, &b, it);
|
||||
i = ASN1_item_i2d(reinterpret_cast<ASN1_VALUE *>(x), &b, it);
|
||||
if (b == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
+1
-1
@@ -58,7 +58,7 @@
|
||||
#include <CCryptoBoringSSL_bytestring.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
#include <CCryptoBoringSSL_time.h>
|
||||
#include <CCryptoBoringSSL_posix_time.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
+1
-1
@@ -74,7 +74,7 @@ int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x) {
|
||||
|
||||
int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x) {
|
||||
unsigned char *b = NULL;
|
||||
int n = ASN1_item_i2d(x, &b, it);
|
||||
int n = ASN1_item_i2d(reinterpret_cast<ASN1_VALUE *>(x), &b, it);
|
||||
if (b == NULL) {
|
||||
return 0;
|
||||
}
|
||||
+2
-1
@@ -408,6 +408,7 @@ static ASN1_STRING *bn_to_asn1_string(const BIGNUM *bn, ASN1_STRING *ai,
|
||||
} else {
|
||||
ret = ai;
|
||||
}
|
||||
int len;
|
||||
if (ret == NULL) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
||||
goto err;
|
||||
@@ -419,7 +420,7 @@ static ASN1_STRING *bn_to_asn1_string(const BIGNUM *bn, ASN1_STRING *ai,
|
||||
ret->type = type;
|
||||
}
|
||||
|
||||
int len = BN_num_bytes(bn);
|
||||
len = BN_num_bytes(bn);
|
||||
if (!ASN1_STRING_set(ret, NULL, len) ||
|
||||
!BN_bn2bin_padded(ret->data, len, bn)) {
|
||||
goto err;
|
||||
+18
-16
@@ -97,22 +97,22 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in,
|
||||
int error;
|
||||
switch (inform) {
|
||||
case MBSTRING_BMP:
|
||||
decode_func = cbs_get_ucs2_be;
|
||||
decode_func = CBS_get_ucs2_be;
|
||||
error = ASN1_R_INVALID_BMPSTRING;
|
||||
break;
|
||||
|
||||
case MBSTRING_UNIV:
|
||||
decode_func = cbs_get_utf32_be;
|
||||
decode_func = CBS_get_utf32_be;
|
||||
error = ASN1_R_INVALID_UNIVERSALSTRING;
|
||||
break;
|
||||
|
||||
case MBSTRING_UTF8:
|
||||
decode_func = cbs_get_utf8;
|
||||
decode_func = CBS_get_utf8;
|
||||
error = ASN1_R_INVALID_UTF8STRING;
|
||||
break;
|
||||
|
||||
case MBSTRING_ASC:
|
||||
decode_func = cbs_get_latin1;
|
||||
decode_func = CBS_get_latin1;
|
||||
error = ERR_R_INTERNAL_ERROR; // Latin-1 inputs are never invalid.
|
||||
break;
|
||||
|
||||
@@ -162,7 +162,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in,
|
||||
}
|
||||
|
||||
nchar++;
|
||||
utf8_len += cbb_get_utf8_len(c);
|
||||
utf8_len += CBB_get_utf8_len(c);
|
||||
if (maxsize > 0 && nchar > (size_t)maxsize) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_LONG);
|
||||
ERR_add_error_dataf("maxsize=%zu", (size_t)maxsize);
|
||||
@@ -178,7 +178,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in,
|
||||
|
||||
// Now work out output format and string type
|
||||
int str_type;
|
||||
int (*encode_func)(CBB *, uint32_t) = cbb_add_latin1;
|
||||
int (*encode_func)(CBB *, uint32_t) = CBB_add_latin1;
|
||||
size_t size_estimate = nchar;
|
||||
int outform = MBSTRING_ASC;
|
||||
if (mask & B_ASN1_PRINTABLESTRING) {
|
||||
@@ -190,17 +190,17 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in,
|
||||
} else if (mask & B_ASN1_BMPSTRING) {
|
||||
str_type = V_ASN1_BMPSTRING;
|
||||
outform = MBSTRING_BMP;
|
||||
encode_func = cbb_add_ucs2_be;
|
||||
encode_func = CBB_add_ucs2_be;
|
||||
size_estimate = 2 * nchar;
|
||||
} else if (mask & B_ASN1_UNIVERSALSTRING) {
|
||||
str_type = V_ASN1_UNIVERSALSTRING;
|
||||
encode_func = cbb_add_utf32_be;
|
||||
encode_func = CBB_add_utf32_be;
|
||||
size_estimate = 4 * nchar;
|
||||
outform = MBSTRING_UNIV;
|
||||
} else if (mask & B_ASN1_UTF8STRING) {
|
||||
str_type = V_ASN1_UTF8STRING;
|
||||
outform = MBSTRING_UTF8;
|
||||
encode_func = cbb_add_utf8;
|
||||
encode_func = CBB_add_utf8;
|
||||
size_estimate = utf8_len;
|
||||
} else {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_CHARACTERS);
|
||||
@@ -226,6 +226,8 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in,
|
||||
CBB cbb;
|
||||
CBB_zero(&cbb);
|
||||
// If both the same type just copy across
|
||||
uint8_t *data = NULL;
|
||||
size_t data_len = 0;
|
||||
if (inform == outform) {
|
||||
if (!ASN1_STRING_set(dest, in, len)) {
|
||||
goto err;
|
||||
@@ -245,12 +247,12 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in,
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
uint8_t *data = NULL;
|
||||
size_t data_len;
|
||||
if (// OpenSSL historically NUL-terminated this value with a single byte,
|
||||
// even for |MBSTRING_BMP| and |MBSTRING_UNIV|.
|
||||
!CBB_add_u8(&cbb, 0) || !CBB_finish(&cbb, &data, &data_len) ||
|
||||
data_len < 1 || data_len > INT_MAX) {
|
||||
if (/* OpenSSL historically NUL-terminated this value with a single byte,
|
||||
* even for |MBSTRING_BMP| and |MBSTRING_UNIV|. */
|
||||
!CBB_add_u8(&cbb, 0) || //
|
||||
!CBB_finish(&cbb, &data, &data_len) || //
|
||||
data_len < 1 || //
|
||||
data_len > INT_MAX) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
|
||||
OPENSSL_free(data);
|
||||
goto err;
|
||||
@@ -272,7 +274,7 @@ int asn1_is_printable(uint32_t value) {
|
||||
if (value > 0x7f) {
|
||||
return 0;
|
||||
}
|
||||
return OPENSSL_isalnum(value) || //
|
||||
return OPENSSL_isalnum(value) || //
|
||||
value == ' ' || value == '\'' || value == '(' || value == ')' ||
|
||||
value == '+' || value == ',' || value == '-' || value == '.' ||
|
||||
value == '/' || value == ':' || value == '=' || value == '?';
|
||||
+1
-1
@@ -114,7 +114,7 @@ int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a) {
|
||||
int len = i2t_ASN1_OBJECT(buf, sizeof(buf), a);
|
||||
if (len > (int)sizeof(buf) - 1) {
|
||||
// The input was truncated. Allocate a buffer that fits.
|
||||
allocated = OPENSSL_malloc(len + 1);
|
||||
allocated = reinterpret_cast<char *>(OPENSSL_malloc(len + 1));
|
||||
if (allocated == NULL) {
|
||||
return -1;
|
||||
}
|
||||
File renamed without changes.
+8
-21
@@ -68,6 +68,7 @@
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
|
||||
#include "../bytestring/internal.h"
|
||||
#include "../internal.h"
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
@@ -137,19 +138,19 @@ static int do_buf(const unsigned char *buf, int buflen, int encoding,
|
||||
int get_char_error;
|
||||
switch (encoding) {
|
||||
case MBSTRING_UNIV:
|
||||
get_char = cbs_get_utf32_be;
|
||||
get_char = CBS_get_utf32_be;
|
||||
get_char_error = ASN1_R_INVALID_UNIVERSALSTRING;
|
||||
break;
|
||||
case MBSTRING_BMP:
|
||||
get_char = cbs_get_ucs2_be;
|
||||
get_char = CBS_get_ucs2_be;
|
||||
get_char_error = ASN1_R_INVALID_BMPSTRING;
|
||||
break;
|
||||
case MBSTRING_ASC:
|
||||
get_char = cbs_get_latin1;
|
||||
get_char = CBS_get_latin1;
|
||||
get_char_error = ERR_R_INTERNAL_ERROR; // Should not be possible.
|
||||
break;
|
||||
case MBSTRING_UTF8:
|
||||
get_char = cbs_get_utf8;
|
||||
get_char = CBS_get_utf8;
|
||||
get_char_error = ASN1_R_INVALID_UTF8STRING;
|
||||
break;
|
||||
default:
|
||||
@@ -172,7 +173,7 @@ static int do_buf(const unsigned char *buf, int buflen, int encoding,
|
||||
uint8_t utf8_buf[6];
|
||||
CBB utf8_cbb;
|
||||
CBB_init_fixed(&utf8_cbb, utf8_buf, sizeof(utf8_buf));
|
||||
if (!cbb_add_utf8(&utf8_cbb, c)) {
|
||||
if (!CBB_add_utf8(&utf8_cbb, c)) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
|
||||
return 1;
|
||||
}
|
||||
@@ -238,22 +239,8 @@ static int do_dump(unsigned long flags, BIO *out, const ASN1_STRING *str) {
|
||||
// Placing the ASN1_STRING in a temporary ASN1_TYPE allows the DER encoding
|
||||
// to readily obtained.
|
||||
ASN1_TYPE t;
|
||||
t.type = str->type;
|
||||
// Negative INTEGER and ENUMERATED values are the only case where
|
||||
// |ASN1_STRING| and |ASN1_TYPE| types do not match.
|
||||
//
|
||||
// TODO(davidben): There are also some type fields which, in |ASN1_TYPE|, do
|
||||
// not correspond to |ASN1_STRING|. It is unclear whether those are allowed
|
||||
// in |ASN1_STRING| at all, or what the space of allowed types is.
|
||||
// |ASN1_item_ex_d2i| will never produce such a value so, for now, we say
|
||||
// this is an invalid input. But this corner of the library in general
|
||||
// should be more robust.
|
||||
if (t.type == V_ASN1_NEG_INTEGER) {
|
||||
t.type = V_ASN1_INTEGER;
|
||||
} else if (t.type == V_ASN1_NEG_ENUMERATED) {
|
||||
t.type = V_ASN1_ENUMERATED;
|
||||
}
|
||||
t.value.asn1_string = (ASN1_STRING *)str;
|
||||
OPENSSL_memset(&t, 0, sizeof(ASN1_TYPE));
|
||||
asn1_type_set0_string(&t, (ASN1_STRING *)str);
|
||||
unsigned char *der_buf = NULL;
|
||||
int der_len = i2d_ASN1_TYPE(&t, &der_buf);
|
||||
if (der_len < 0) {
|
||||
+7
-4
@@ -159,7 +159,8 @@ static int table_cmp(const ASN1_STRING_TABLE *a, const ASN1_STRING_TABLE *b) {
|
||||
}
|
||||
|
||||
static int table_cmp_void(const void *a, const void *b) {
|
||||
return table_cmp(a, b);
|
||||
return table_cmp(reinterpret_cast<const ASN1_STRING_TABLE *>(a),
|
||||
reinterpret_cast<const ASN1_STRING_TABLE *>(b));
|
||||
}
|
||||
|
||||
static uint32_t table_hash(const ASN1_STRING_TABLE *tbl) {
|
||||
@@ -169,9 +170,9 @@ static uint32_t table_hash(const ASN1_STRING_TABLE *tbl) {
|
||||
static const ASN1_STRING_TABLE *asn1_string_table_get(int nid) {
|
||||
ASN1_STRING_TABLE key;
|
||||
key.nid = nid;
|
||||
const ASN1_STRING_TABLE *tbl =
|
||||
const ASN1_STRING_TABLE *tbl = reinterpret_cast<ASN1_STRING_TABLE *>(
|
||||
bsearch(&key, tbl_standard, OPENSSL_ARRAY_SIZE(tbl_standard),
|
||||
sizeof(ASN1_STRING_TABLE), table_cmp_void);
|
||||
sizeof(ASN1_STRING_TABLE), table_cmp_void));
|
||||
if (tbl != NULL) {
|
||||
return tbl;
|
||||
}
|
||||
@@ -198,6 +199,7 @@ int ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize,
|
||||
int ret = 0;
|
||||
CRYPTO_MUTEX_lock_write(&string_tables_lock);
|
||||
|
||||
ASN1_STRING_TABLE *tbl = NULL;
|
||||
if (string_tables == NULL) {
|
||||
string_tables = lh_ASN1_STRING_TABLE_new(table_hash, table_cmp);
|
||||
if (string_tables == NULL) {
|
||||
@@ -214,7 +216,8 @@ int ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize,
|
||||
}
|
||||
}
|
||||
|
||||
ASN1_STRING_TABLE *tbl = OPENSSL_malloc(sizeof(ASN1_STRING_TABLE));
|
||||
tbl = reinterpret_cast<ASN1_STRING_TABLE *>(
|
||||
OPENSSL_malloc(sizeof(ASN1_STRING_TABLE)));
|
||||
if (tbl == NULL) {
|
||||
goto err;
|
||||
}
|
||||
+1
-1
@@ -55,7 +55,7 @@
|
||||
* [including the GNU Public Licence.] */
|
||||
|
||||
#include <CCryptoBoringSSL_asn1.h>
|
||||
#include <CCryptoBoringSSL_time.h>
|
||||
#include <CCryptoBoringSSL_posix_time.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
+23
-5
@@ -56,7 +56,8 @@
|
||||
|
||||
#include <CCryptoBoringSSL_asn1.h>
|
||||
|
||||
#include <CCryptoBoringSSL_asn1t.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
#include <CCryptoBoringSSL_obj.h>
|
||||
@@ -89,6 +90,23 @@ const void *asn1_type_value_as_pointer(const ASN1_TYPE *a) {
|
||||
}
|
||||
}
|
||||
|
||||
void asn1_type_set0_string(ASN1_TYPE *a, ASN1_STRING *str) {
|
||||
// |ASN1_STRING| types are almost the same as |ASN1_TYPE| types, except that
|
||||
// the negative flag is not reflected into |ASN1_TYPE|.
|
||||
int type = str->type;
|
||||
if (type == V_ASN1_NEG_INTEGER) {
|
||||
type = V_ASN1_INTEGER;
|
||||
} else if (type == V_ASN1_NEG_ENUMERATED) {
|
||||
type = V_ASN1_ENUMERATED;
|
||||
}
|
||||
|
||||
// These types are not |ASN1_STRING| types and use a different
|
||||
// representation when stored in |ASN1_TYPE|.
|
||||
assert(type != V_ASN1_NULL && type != V_ASN1_OBJECT &&
|
||||
type != V_ASN1_BOOLEAN);
|
||||
ASN1_TYPE_set(a, type, str);
|
||||
}
|
||||
|
||||
void asn1_type_cleanup(ASN1_TYPE *a) {
|
||||
switch (a->type) {
|
||||
case V_ASN1_NULL:
|
||||
@@ -119,10 +137,10 @@ void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value) {
|
||||
a->value.boolean = value ? ASN1_BOOLEAN_TRUE : ASN1_BOOLEAN_FALSE;
|
||||
break;
|
||||
case V_ASN1_OBJECT:
|
||||
a->value.object = value;
|
||||
a->value.object = reinterpret_cast<ASN1_OBJECT *>(value);
|
||||
break;
|
||||
default:
|
||||
a->value.asn1_string = value;
|
||||
a->value.asn1_string = reinterpret_cast<ASN1_STRING *>(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -133,14 +151,14 @@ int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value) {
|
||||
ASN1_TYPE_set(a, type, p);
|
||||
} else if (type == V_ASN1_OBJECT) {
|
||||
ASN1_OBJECT *odup;
|
||||
odup = OBJ_dup(value);
|
||||
odup = OBJ_dup(reinterpret_cast<const ASN1_OBJECT *>(value));
|
||||
if (!odup) {
|
||||
return 0;
|
||||
}
|
||||
ASN1_TYPE_set(a, type, odup);
|
||||
} else {
|
||||
ASN1_STRING *sdup;
|
||||
sdup = ASN1_STRING_dup(value);
|
||||
sdup = ASN1_STRING_dup(reinterpret_cast<const ASN1_STRING *>(value));
|
||||
if (!sdup) {
|
||||
return 0;
|
||||
}
|
||||
+1
-1
@@ -58,7 +58,7 @@
|
||||
#include <CCryptoBoringSSL_bytestring.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
#include <CCryptoBoringSSL_time.h>
|
||||
#include <CCryptoBoringSSL_posix_time.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
+15
-7
@@ -102,6 +102,15 @@ OPENSSL_DECLARE_ERROR_REASON(ASN1, UNKNOWN_FORMAT)
|
||||
OPENSSL_DECLARE_ERROR_REASON(ASN1, UNKNOWN_TAG)
|
||||
OPENSSL_DECLARE_ERROR_REASON(ASN1, UNSUPPORTED_TYPE)
|
||||
|
||||
// Limit |ASN1_STRING|s to 64 MiB of data. Most of this module, as well as
|
||||
// downstream code, does not correctly handle overflow. We cap string fields
|
||||
// more tightly than strictly necessary to fit in |int|. This is not expected to
|
||||
// impact real world uses of this field.
|
||||
//
|
||||
// In particular, this limit is small enough that the bit count of a BIT STRING
|
||||
// comfortably fits in an |int|, with room for arithmetic.
|
||||
#define ASN1_STRING_MAX (64 * 1024 * 1024)
|
||||
|
||||
static void asn1_put_length(unsigned char **pp, int length);
|
||||
|
||||
int ASN1_get_object(const unsigned char **inp, long *out_len, int *out_tag,
|
||||
@@ -262,7 +271,7 @@ ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *str) {
|
||||
}
|
||||
|
||||
int ASN1_STRING_set(ASN1_STRING *str, const void *_data, ossl_ssize_t len_s) {
|
||||
const char *data = _data;
|
||||
const char *data = reinterpret_cast<const char *>(_data);
|
||||
size_t len;
|
||||
if (len_s < 0) {
|
||||
if (data == NULL) {
|
||||
@@ -273,9 +282,8 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, ossl_ssize_t len_s) {
|
||||
len = (size_t)len_s;
|
||||
}
|
||||
|
||||
// |ASN1_STRING| cannot represent strings that exceed |int|, and we must
|
||||
// reserve space for a trailing NUL below.
|
||||
if (len > INT_MAX || len + 1 < len) {
|
||||
static_assert(ASN1_STRING_MAX < INT_MAX, "len will not overflow int");
|
||||
if (len > ASN1_STRING_MAX) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ERR_R_OVERFLOW);
|
||||
return 0;
|
||||
}
|
||||
@@ -283,9 +291,9 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, ossl_ssize_t len_s) {
|
||||
if (str->length <= (int)len || str->data == NULL) {
|
||||
unsigned char *c = str->data;
|
||||
if (c == NULL) {
|
||||
str->data = OPENSSL_malloc(len + 1);
|
||||
str->data = reinterpret_cast<uint8_t *>(OPENSSL_malloc(len + 1));
|
||||
} else {
|
||||
str->data = OPENSSL_realloc(c, len + 1);
|
||||
str->data = reinterpret_cast<uint8_t *>(OPENSSL_realloc(c, len + 1));
|
||||
}
|
||||
|
||||
if (str->data == NULL) {
|
||||
@@ -307,7 +315,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, ossl_ssize_t len_s) {
|
||||
|
||||
void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len) {
|
||||
OPENSSL_free(str->data);
|
||||
str->data = data;
|
||||
str->data = reinterpret_cast<uint8_t *>(data);
|
||||
str->length = len;
|
||||
}
|
||||
|
||||
File renamed without changes.
+2
-2
@@ -62,7 +62,7 @@
|
||||
|
||||
ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **out) {
|
||||
uint8_t *new_data = NULL;
|
||||
int len = ASN1_item_i2d(obj, &new_data, it);
|
||||
int len = ASN1_item_i2d(reinterpret_cast<ASN1_VALUE *>(obj), &new_data, it);
|
||||
if (len <= 0) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ENCODE_ERROR);
|
||||
return NULL;
|
||||
@@ -91,7 +91,7 @@ void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it) {
|
||||
void *ret = ASN1_item_d2i(NULL, &p, oct->length, it);
|
||||
if (ret == NULL || p != oct->data + oct->length) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
|
||||
ASN1_item_free(ret, it);
|
||||
ASN1_item_free(reinterpret_cast<ASN1_VALUE *>(ret), it);
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
File renamed without changes.
File renamed without changes.
@@ -76,18 +76,12 @@ extern "C" {
|
||||
// returned. On failure NULL is returned.
|
||||
OPENSSL_EXPORT struct tm *OPENSSL_gmtime(const time_t *time, struct tm *result);
|
||||
|
||||
// OPENSSL_timegm converts a time value between the years 0 and 9999 in |tm| to
|
||||
// a time_t value in |out|. One is returned on success, zero is returned on
|
||||
// failure. It is a failure if the converted time can not be represented in a
|
||||
// time_t, or if the tm contains out of range values.
|
||||
OPENSSL_EXPORT int OPENSSL_timegm(const struct tm *tm, time_t *out);
|
||||
|
||||
// OPENSSL_gmtime_adj returns one on success, and updates |tm| by adding
|
||||
// |offset_day| days and |offset_sec| seconds. It returns zero on failure. |tm|
|
||||
// must be in the range of year 0000 to 9999 both before and after the update or
|
||||
// a failure will be returned.
|
||||
OPENSSL_EXPORT int OPENSSL_gmtime_adj(struct tm *tm, int offset_day,
|
||||
long offset_sec);
|
||||
int64_t offset_sec);
|
||||
|
||||
// OPENSSL_gmtime_diff calculates the difference between |from| and |to|. It
|
||||
// returns one, and outputs the difference as a number of days and seconds in
|
||||
@@ -210,6 +204,10 @@ void asn1_encoding_clear(ASN1_ENCODING *enc);
|
||||
// a pointer.
|
||||
const void *asn1_type_value_as_pointer(const ASN1_TYPE *a);
|
||||
|
||||
// asn1_type_set0_string sets |a|'s value to the object represented by |str| and
|
||||
// takes ownership of |str|.
|
||||
void asn1_type_set0_string(ASN1_TYPE *a, ASN1_STRING *str);
|
||||
|
||||
// asn1_type_cleanup releases memory associated with |a|'s value, without
|
||||
// freeing |a| itself.
|
||||
void asn1_type_cleanup(ASN1_TYPE *a);
|
||||
@@ -256,7 +254,6 @@ typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
typedef struct ASN1_EXTERN_FUNCS_st {
|
||||
ASN1_ex_new_func *asn1_ex_new;
|
||||
ASN1_ex_free_func *asn1_ex_free;
|
||||
ASN1_ex_free_func *asn1_ex_clear;
|
||||
ASN1_ex_d2i *asn1_ex_d2i;
|
||||
ASN1_ex_i2d *asn1_ex_i2d;
|
||||
} ASN1_EXTERN_FUNCS;
|
||||
|
||||
+52
-41
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2022, Google Inc.
|
||||
/* Copyright 2022 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -15,7 +15,7 @@
|
||||
// Time conversion to/from POSIX time_t and struct tm, with no support
|
||||
// for time zones other than UTC
|
||||
|
||||
#include <CCryptoBoringSSL_time.h>
|
||||
#include <CCryptoBoringSSL_posix_time.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
@@ -26,12 +26,12 @@
|
||||
#include "internal.h"
|
||||
|
||||
#define SECS_PER_HOUR (60 * 60)
|
||||
#define SECS_PER_DAY (24 * SECS_PER_HOUR)
|
||||
#define SECS_PER_DAY (INT64_C(24) * SECS_PER_HOUR)
|
||||
|
||||
|
||||
// Is a year/month/day combination valid, in the range from year 0000
|
||||
// to 9999?
|
||||
static int is_valid_date(int year, int month, int day) {
|
||||
static int is_valid_date(int64_t year, int64_t month, int64_t day) {
|
||||
if (day < 1 || month < 1 || year < 0 || year > 9999) {
|
||||
return 0;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ static int is_valid_date(int year, int month, int day) {
|
||||
|
||||
// Is a time valid? Leap seconds of 60 are not considered valid, as
|
||||
// the POSIX time in seconds does not include them.
|
||||
static int is_valid_time(int hours, int minutes, int seconds) {
|
||||
static int is_valid_time(int64_t hours, int64_t minutes, int64_t seconds) {
|
||||
if (hours < 0 || minutes < 0 || seconds < 0 || hours > 23 || minutes > 59 ||
|
||||
seconds > 59) {
|
||||
return 0;
|
||||
@@ -70,17 +70,22 @@ static int is_valid_time(int hours, int minutes, int seconds) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Is a int64 time representing a time within our expected range?
|
||||
static int is_valid_epoch_time(int64_t time) {
|
||||
// 0000-01-01 00:00:00 UTC to 9999-12-31 23:59:59 UTC
|
||||
return (int64_t)-62167219200 <= time && time <= (int64_t)253402300799;
|
||||
// 0000-01-01 00:00:00 UTC
|
||||
#define MIN_POSIX_TIME INT64_C(-62167219200)
|
||||
// 9999-12-31 23:59:59 UTC
|
||||
#define MAX_POSIX_TIME INT64_C(253402300799)
|
||||
|
||||
// Is an int64 time within our expected range?
|
||||
static int is_valid_posix_time(int64_t time) {
|
||||
return MIN_POSIX_TIME <= time && time <= MAX_POSIX_TIME;
|
||||
}
|
||||
|
||||
// Inspired by algorithms presented in
|
||||
// https://howardhinnant.github.io/date_algorithms.html
|
||||
// (Public Domain)
|
||||
static int posix_time_from_utc(int year, int month, int day, int hours,
|
||||
int minutes, int seconds, int64_t *out_time) {
|
||||
static int posix_time_from_utc(int64_t year, int64_t month, int64_t day,
|
||||
int64_t hours, int64_t minutes, int64_t seconds,
|
||||
int64_t *out_time) {
|
||||
if (!is_valid_date(year, month, day) ||
|
||||
!is_valid_time(hours, minutes, seconds)) {
|
||||
return 0;
|
||||
@@ -108,7 +113,7 @@ static int posix_time_from_utc(int year, int month, int day, int hours,
|
||||
static int utc_from_posix_time(int64_t time, int *out_year, int *out_month,
|
||||
int *out_day, int *out_hours, int *out_minutes,
|
||||
int *out_seconds) {
|
||||
if (!is_valid_epoch_time(time)) {
|
||||
if (!is_valid_posix_time(time)) {
|
||||
return 0;
|
||||
}
|
||||
int64_t days = time / SECS_PER_DAY;
|
||||
@@ -143,19 +148,21 @@ static int utc_from_posix_time(int64_t time, int *out_year, int *out_month,
|
||||
}
|
||||
|
||||
int OPENSSL_tm_to_posix(const struct tm *tm, int64_t *out) {
|
||||
return posix_time_from_utc(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec, out);
|
||||
return posix_time_from_utc(tm->tm_year + INT64_C(1900),
|
||||
tm->tm_mon + INT64_C(1), tm->tm_mday, tm->tm_hour,
|
||||
tm->tm_min, tm->tm_sec, out);
|
||||
}
|
||||
|
||||
int OPENSSL_posix_to_tm(int64_t time, struct tm *out_tm) {
|
||||
memset(out_tm, 0, sizeof(struct tm));
|
||||
if (!utc_from_posix_time(time, &out_tm->tm_year, &out_tm->tm_mon,
|
||||
&out_tm->tm_mday, &out_tm->tm_hour, &out_tm->tm_min,
|
||||
&out_tm->tm_sec)) {
|
||||
struct tm tmp_tm = {};
|
||||
if (!utc_from_posix_time(time, &tmp_tm.tm_year, &tmp_tm.tm_mon,
|
||||
&tmp_tm.tm_mday, &tmp_tm.tm_hour, &tmp_tm.tm_min,
|
||||
&tmp_tm.tm_sec)) {
|
||||
return 0;
|
||||
}
|
||||
out_tm->tm_year -= 1900;
|
||||
out_tm->tm_mon -= 1;
|
||||
tmp_tm.tm_year -= 1900;
|
||||
tmp_tm.tm_mon -= 1;
|
||||
*out_tm = tmp_tm;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -187,43 +194,47 @@ struct tm *OPENSSL_gmtime(const time_t *time, struct tm *out_tm) {
|
||||
return out_tm;
|
||||
}
|
||||
|
||||
int OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec) {
|
||||
int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, int64_t offset_sec) {
|
||||
int64_t posix_time;
|
||||
if (!posix_time_from_utc(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec, &posix_time)) {
|
||||
if (!OPENSSL_tm_to_posix(tm, &posix_time)) {
|
||||
return 0;
|
||||
}
|
||||
if (!utc_from_posix_time(
|
||||
posix_time + (int64_t)off_day * SECS_PER_DAY + offset_sec,
|
||||
&tm->tm_year, &tm->tm_mon, &tm->tm_mday, &tm->tm_hour, &tm->tm_min,
|
||||
&tm->tm_sec)) {
|
||||
static_assert(INT_MAX <= INT64_MAX / SECS_PER_DAY,
|
||||
"day offset in seconds cannot overflow");
|
||||
static_assert(MAX_POSIX_TIME <= INT64_MAX - INT_MAX * SECS_PER_DAY,
|
||||
"addition cannot overflow");
|
||||
static_assert(MIN_POSIX_TIME >= INT64_MIN - INT_MIN * SECS_PER_DAY,
|
||||
"addition cannot underflow");
|
||||
posix_time += offset_day * SECS_PER_DAY;
|
||||
if (posix_time > 0 && offset_sec > INT64_MAX - posix_time) {
|
||||
return 0;
|
||||
}
|
||||
if (posix_time < 0 && offset_sec < INT64_MIN - posix_time) {
|
||||
return 0;
|
||||
}
|
||||
posix_time += offset_sec;
|
||||
|
||||
if (!OPENSSL_posix_to_tm(posix_time, tm)) {
|
||||
return 0;
|
||||
}
|
||||
tm->tm_year -= 1900;
|
||||
tm->tm_mon -= 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int OPENSSL_gmtime_diff(int *out_days, int *out_secs, const struct tm *from,
|
||||
const struct tm *to) {
|
||||
int64_t time_to;
|
||||
if (!posix_time_from_utc(to->tm_year + 1900, to->tm_mon + 1, to->tm_mday,
|
||||
to->tm_hour, to->tm_min, to->tm_sec, &time_to)) {
|
||||
return 0;
|
||||
}
|
||||
int64_t time_from;
|
||||
if (!posix_time_from_utc(from->tm_year + 1900, from->tm_mon + 1,
|
||||
from->tm_mday, from->tm_hour, from->tm_min,
|
||||
from->tm_sec, &time_from)) {
|
||||
int64_t time_to, time_from;
|
||||
if (!OPENSSL_tm_to_posix(to, &time_to) ||
|
||||
!OPENSSL_tm_to_posix(from, &time_from)) {
|
||||
return 0;
|
||||
}
|
||||
// Times are in range, so these calculations can not overflow.
|
||||
static_assert(SECS_PER_DAY <= INT_MAX, "seconds per day does not fit in int");
|
||||
static_assert((MAX_POSIX_TIME - MIN_POSIX_TIME) / SECS_PER_DAY <= INT_MAX,
|
||||
"range of valid POSIX times, in days, does not fit in int");
|
||||
int64_t timediff = time_to - time_from;
|
||||
int64_t daydiff = timediff / SECS_PER_DAY;
|
||||
timediff %= SECS_PER_DAY;
|
||||
if (daydiff > INT_MAX || daydiff < INT_MIN) {
|
||||
return 0;
|
||||
}
|
||||
*out_secs = (int)timediff;
|
||||
*out_days = (int)daydiff;
|
||||
return 1;
|
||||
+7
-6
@@ -282,7 +282,8 @@ static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
|
||||
goto err;
|
||||
}
|
||||
const ASN1_EXTERN_FUNCS *ef = it->funcs;
|
||||
const ASN1_EXTERN_FUNCS *ef =
|
||||
reinterpret_cast<const ASN1_EXTERN_FUNCS *>(it->funcs);
|
||||
return ef->asn1_ex_d2i(pval, in, len, it, opt, NULL);
|
||||
}
|
||||
|
||||
@@ -294,7 +295,7 @@ static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
goto err;
|
||||
}
|
||||
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
|
||||
ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
|
||||
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL)) {
|
||||
goto auxerr;
|
||||
@@ -379,7 +380,7 @@ static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
goto err;
|
||||
}
|
||||
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
|
||||
ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
|
||||
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL)) {
|
||||
goto auxerr;
|
||||
@@ -850,7 +851,7 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, long len,
|
||||
if (utype == V_ASN1_BMPSTRING) {
|
||||
while (CBS_len(&cbs) != 0) {
|
||||
uint32_t c;
|
||||
if (!cbs_get_ucs2_be(&cbs, &c)) {
|
||||
if (!CBS_get_ucs2_be(&cbs, &c)) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BMPSTRING);
|
||||
goto err;
|
||||
}
|
||||
@@ -859,7 +860,7 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, long len,
|
||||
if (utype == V_ASN1_UNIVERSALSTRING) {
|
||||
while (CBS_len(&cbs) != 0) {
|
||||
uint32_t c;
|
||||
if (!cbs_get_utf32_be(&cbs, &c)) {
|
||||
if (!CBS_get_utf32_be(&cbs, &c)) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_UNIVERSALSTRING);
|
||||
goto err;
|
||||
}
|
||||
@@ -868,7 +869,7 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, long len,
|
||||
if (utype == V_ASN1_UTF8STRING) {
|
||||
while (CBS_len(&cbs) != 0) {
|
||||
uint32_t c;
|
||||
if (!cbs_get_utf8(&cbs, &c)) {
|
||||
if (!CBS_get_utf8(&cbs, &c)) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_UTF8STRING);
|
||||
goto err;
|
||||
}
|
||||
+9
-11
@@ -90,7 +90,7 @@ int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it) {
|
||||
if (len <= 0) {
|
||||
return len;
|
||||
}
|
||||
buf = OPENSSL_malloc(len);
|
||||
buf = reinterpret_cast<uint8_t *>(OPENSSL_malloc(len));
|
||||
if (!buf) {
|
||||
return -1;
|
||||
}
|
||||
@@ -191,7 +191,8 @@ int asn1_item_ex_i2d_opt(ASN1_VALUE **pval, unsigned char **out,
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
|
||||
return -1;
|
||||
}
|
||||
const ASN1_EXTERN_FUNCS *ef = it->funcs;
|
||||
const ASN1_EXTERN_FUNCS *ef =
|
||||
reinterpret_cast<const ASN1_EXTERN_FUNCS *>(it->funcs);
|
||||
int ret = ef->asn1_ex_i2d(pval, out, it);
|
||||
if (ret == 0) {
|
||||
// |asn1_ex_i2d| should never return zero. We have already checked
|
||||
@@ -424,7 +425,8 @@ typedef struct {
|
||||
} DER_ENC;
|
||||
|
||||
static int der_cmp(const void *a, const void *b) {
|
||||
const DER_ENC *d1 = a, *d2 = b;
|
||||
const DER_ENC *d1 = reinterpret_cast<const DER_ENC *>(a),
|
||||
*d2 = reinterpret_cast<const DER_ENC *>(b);
|
||||
int cmplen, i;
|
||||
cmplen = (d1->length < d2->length) ? d1->length : d2->length;
|
||||
i = OPENSSL_memcmp(d1->data, d2->data, cmplen);
|
||||
@@ -452,20 +454,16 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (sk_ASN1_VALUE_num(sk) > ((size_t)-1) / sizeof(DER_ENC)) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ERR_R_OVERFLOW);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
unsigned char *const buf = OPENSSL_malloc(skcontlen);
|
||||
DER_ENC *encoded = OPENSSL_malloc(sk_ASN1_VALUE_num(sk) * sizeof(*encoded));
|
||||
uint8_t *const buf = reinterpret_cast<uint8_t *>(OPENSSL_malloc(skcontlen));
|
||||
DER_ENC *encoded = reinterpret_cast<DER_ENC *>(
|
||||
OPENSSL_calloc(sk_ASN1_VALUE_num(sk), sizeof(*encoded)));
|
||||
uint8_t *p = buf;
|
||||
if (encoded == NULL || buf == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
// Encode all the elements into |buf| and populate |encoded|.
|
||||
unsigned char *p = buf;
|
||||
for (size_t i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
|
||||
ASN1_VALUE *skitem = sk_ASN1_VALUE_value(sk, i);
|
||||
encoded[i].data = p;
|
||||
+14
-20
@@ -70,9 +70,6 @@ void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it) {
|
||||
}
|
||||
|
||||
void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
const ASN1_TEMPLATE *tt = NULL, *seqtt;
|
||||
const ASN1_EXTERN_FUNCS *ef;
|
||||
int i;
|
||||
if (!pval) {
|
||||
return;
|
||||
}
|
||||
@@ -94,19 +91,17 @@ void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
break;
|
||||
|
||||
case ASN1_ITYPE_CHOICE: {
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
|
||||
ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
|
||||
if (asn1_cb) {
|
||||
i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL);
|
||||
if (i == 2) {
|
||||
if (asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL) == 2) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
i = asn1_get_choice_selector(pval, it);
|
||||
int i = asn1_get_choice_selector(pval, it);
|
||||
if ((i >= 0) && (i < it->tcount)) {
|
||||
ASN1_VALUE **pchval;
|
||||
tt = it->templates + i;
|
||||
pchval = asn1_get_field_ptr(pval, tt);
|
||||
const ASN1_TEMPLATE *tt = it->templates + i;
|
||||
ASN1_VALUE **pchval = asn1_get_field_ptr(pval, tt);
|
||||
ASN1_template_free(pchval, tt);
|
||||
}
|
||||
if (asn1_cb) {
|
||||
@@ -117,22 +112,23 @@ void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
break;
|
||||
}
|
||||
|
||||
case ASN1_ITYPE_EXTERN:
|
||||
ef = it->funcs;
|
||||
case ASN1_ITYPE_EXTERN: {
|
||||
const ASN1_EXTERN_FUNCS *ef =
|
||||
reinterpret_cast<const ASN1_EXTERN_FUNCS *>(it->funcs);
|
||||
if (ef && ef->asn1_ex_free) {
|
||||
ef->asn1_ex_free(pval, it);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ASN1_ITYPE_SEQUENCE: {
|
||||
if (!asn1_refcount_dec_and_test_zero(pval, it)) {
|
||||
return;
|
||||
}
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
|
||||
ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
|
||||
if (asn1_cb) {
|
||||
i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL);
|
||||
if (i == 2) {
|
||||
if (asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL) == 2) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -140,14 +136,12 @@ void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
// If we free up as normal we will invalidate any ANY DEFINED BY
|
||||
// field and we wont be able to determine the type of the field it
|
||||
// defines. So free up in reverse order.
|
||||
tt = it->templates + it->tcount - 1;
|
||||
for (i = 0; i < it->tcount; tt--, i++) {
|
||||
ASN1_VALUE **pseqval;
|
||||
seqtt = asn1_do_adb(pval, tt, 0);
|
||||
for (int i = it->tcount - 1; i >= 0; i--) {
|
||||
const ASN1_TEMPLATE *seqtt = asn1_do_adb(pval, &it->templates[i], 0);
|
||||
if (!seqtt) {
|
||||
continue;
|
||||
}
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
ASN1_VALUE **pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
ASN1_template_free(pseqval, seqtt);
|
||||
}
|
||||
if (asn1_cb) {
|
||||
+9
-17
@@ -91,7 +91,7 @@ int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
|
||||
switch (it->itype) {
|
||||
case ASN1_ITYPE_EXTERN:
|
||||
ef = it->funcs;
|
||||
ef = reinterpret_cast<const ASN1_EXTERN_FUNCS *>(it->funcs);
|
||||
if (ef && ef->asn1_ex_new) {
|
||||
if (!ef->asn1_ex_new(pval, it)) {
|
||||
goto memerr;
|
||||
@@ -116,7 +116,7 @@ int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
break;
|
||||
|
||||
case ASN1_ITYPE_CHOICE: {
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
|
||||
ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
|
||||
if (asn1_cb) {
|
||||
i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);
|
||||
@@ -127,11 +127,10 @@ int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
*pval = OPENSSL_malloc(it->size);
|
||||
*pval = reinterpret_cast<ASN1_VALUE *>(OPENSSL_zalloc(it->size));
|
||||
if (!*pval) {
|
||||
goto memerr;
|
||||
}
|
||||
OPENSSL_memset(*pval, 0, it->size);
|
||||
asn1_set_choice_selector(pval, -1, it);
|
||||
if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL)) {
|
||||
goto auxerr2;
|
||||
@@ -140,7 +139,7 @@ int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
}
|
||||
|
||||
case ASN1_ITYPE_SEQUENCE: {
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
|
||||
ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
|
||||
if (asn1_cb) {
|
||||
i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);
|
||||
@@ -151,11 +150,10 @@ int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
*pval = OPENSSL_malloc(it->size);
|
||||
*pval = reinterpret_cast<ASN1_VALUE *>(OPENSSL_zalloc(it->size));
|
||||
if (!*pval) {
|
||||
goto memerr;
|
||||
}
|
||||
OPENSSL_memset(*pval, 0, it->size);
|
||||
asn1_refcount_set_one(pval, it);
|
||||
asn1_enc_init(pval, it);
|
||||
for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
|
||||
@@ -185,16 +183,9 @@ auxerr:
|
||||
}
|
||||
|
||||
static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
const ASN1_EXTERN_FUNCS *ef;
|
||||
|
||||
switch (it->itype) {
|
||||
case ASN1_ITYPE_EXTERN:
|
||||
ef = it->funcs;
|
||||
if (ef && ef->asn1_ex_clear) {
|
||||
ef->asn1_ex_clear(pval, it);
|
||||
} else {
|
||||
*pval = NULL;
|
||||
}
|
||||
*pval = NULL;
|
||||
break;
|
||||
|
||||
case ASN1_ITYPE_PRIMITIVE:
|
||||
@@ -276,7 +267,7 @@ static int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
}
|
||||
switch (utype) {
|
||||
case V_ASN1_OBJECT:
|
||||
*pval = (ASN1_VALUE *)OBJ_nid2obj(NID_undef);
|
||||
*pval = (ASN1_VALUE *)OBJ_get_undef();
|
||||
return 1;
|
||||
|
||||
case V_ASN1_BOOLEAN:
|
||||
@@ -288,7 +279,8 @@ static int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
return 1;
|
||||
|
||||
case V_ASN1_ANY: {
|
||||
ASN1_TYPE *typ = OPENSSL_malloc(sizeof(ASN1_TYPE));
|
||||
ASN1_TYPE *typ =
|
||||
reinterpret_cast<ASN1_TYPE *>(OPENSSL_malloc(sizeof(ASN1_TYPE)));
|
||||
if (!typ) {
|
||||
return 0;
|
||||
}
|
||||
File renamed without changes.
+13
-10
@@ -77,7 +77,7 @@
|
||||
|
||||
// Given an ASN1_ITEM CHOICE type return the selector value
|
||||
int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
int *sel = offset2ptr(*pval, it->utype);
|
||||
int *sel = reinterpret_cast<int *>(offset2ptr(*pval, it->utype));
|
||||
return *sel;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
int asn1_set_choice_selector(ASN1_VALUE **pval, int value,
|
||||
const ASN1_ITEM *it) {
|
||||
int *sel, ret;
|
||||
sel = offset2ptr(*pval, it->utype);
|
||||
sel = reinterpret_cast<int *>(offset2ptr(*pval, it->utype));
|
||||
ret = *sel;
|
||||
*sel = value;
|
||||
return ret;
|
||||
@@ -96,11 +96,12 @@ static CRYPTO_refcount_t *asn1_get_references(ASN1_VALUE **pval,
|
||||
if (it->itype != ASN1_ITYPE_SEQUENCE) {
|
||||
return NULL;
|
||||
}
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
|
||||
if (!aux || !(aux->flags & ASN1_AFLG_REFCOUNT)) {
|
||||
return NULL;
|
||||
}
|
||||
return offset2ptr(*pval, aux->ref_offset);
|
||||
return reinterpret_cast<CRYPTO_refcount_t *>(
|
||||
offset2ptr(*pval, aux->ref_offset));
|
||||
}
|
||||
|
||||
void asn1_refcount_set_one(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
@@ -124,11 +125,11 @@ static ASN1_ENCODING *asn1_get_enc_ptr(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
if (!pval || !*pval) {
|
||||
return NULL;
|
||||
}
|
||||
aux = it->funcs;
|
||||
aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
|
||||
if (!aux || !(aux->flags & ASN1_AFLG_ENCODING)) {
|
||||
return NULL;
|
||||
}
|
||||
return offset2ptr(*pval, aux->enc_offset);
|
||||
return reinterpret_cast<ASN1_ENCODING *>(offset2ptr(*pval, aux->enc_offset));
|
||||
}
|
||||
|
||||
void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it) {
|
||||
@@ -163,7 +164,7 @@ int asn1_enc_save(ASN1_VALUE **pval, const uint8_t *in, size_t in_len,
|
||||
enc->buf = buf;
|
||||
enc->enc = (uint8_t *)in;
|
||||
} else {
|
||||
enc->enc = OPENSSL_memdup(in, in_len);
|
||||
enc->enc = reinterpret_cast<uint8_t *>(OPENSSL_memdup(in, in_len));
|
||||
if (!enc->enc) {
|
||||
return 0;
|
||||
}
|
||||
@@ -202,7 +203,8 @@ int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,
|
||||
|
||||
// Given an ASN1_TEMPLATE get a pointer to a field
|
||||
ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) {
|
||||
ASN1_VALUE **pvaltmp = offset2ptr(*pval, tt->offset);
|
||||
ASN1_VALUE **pvaltmp =
|
||||
reinterpret_cast<ASN1_VALUE **>(offset2ptr(*pval, tt->offset));
|
||||
// NOTE for BOOLEAN types the field is just a plain int so we can't return
|
||||
// int **, so settle for (int *).
|
||||
return pvaltmp;
|
||||
@@ -224,9 +226,10 @@ const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,
|
||||
adb = ASN1_ADB_ptr(tt->item);
|
||||
|
||||
// Get the selector field
|
||||
sfld = offset2ptr(*pval, adb->offset);
|
||||
sfld = reinterpret_cast<ASN1_VALUE **>(offset2ptr(*pval, adb->offset));
|
||||
|
||||
// Check if NULL
|
||||
int selector;
|
||||
if (*sfld == NULL) {
|
||||
if (!adb->null_tt) {
|
||||
goto err;
|
||||
@@ -238,7 +241,7 @@ const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,
|
||||
// NB: don't check for NID_undef here because it
|
||||
// might be a legitimate value in the table
|
||||
assert(tt->flags & ASN1_TFLG_ADB_OID);
|
||||
int selector = OBJ_obj2nid((ASN1_OBJECT *)*sfld);
|
||||
selector = OBJ_obj2nid((ASN1_OBJECT *)*sfld);
|
||||
|
||||
// Try to find matching entry in table Maybe should check application types
|
||||
// first to allow application override? Might also be useful to have a flag
|
||||
+13
-17
@@ -121,17 +121,11 @@ int EVP_EncodedLength(size_t *out_len, size_t len) {
|
||||
}
|
||||
|
||||
EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void) {
|
||||
EVP_ENCODE_CTX *ret = OPENSSL_malloc(sizeof(EVP_ENCODE_CTX));
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
OPENSSL_memset(ret, 0, sizeof(EVP_ENCODE_CTX));
|
||||
return ret;
|
||||
return reinterpret_cast<EVP_ENCODE_CTX *>(
|
||||
OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX)));
|
||||
}
|
||||
|
||||
void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx) {
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx) { OPENSSL_free(ctx); }
|
||||
|
||||
void EVP_EncodeInit(EVP_ENCODE_CTX *ctx) {
|
||||
OPENSSL_memset(ctx, 0, sizeof(EVP_ENCODE_CTX));
|
||||
@@ -307,11 +301,15 @@ static int base64_decode_quad(uint8_t *out, size_t *out_num_bytes,
|
||||
const uint32_t v = ((uint32_t)a) << 18 | ((uint32_t)b) << 12 |
|
||||
((uint32_t)c) << 6 | (uint32_t)d;
|
||||
|
||||
const unsigned padding_pattern = (in[0] == '=') << 3 |
|
||||
(in[1] == '=') << 2 |
|
||||
(in[2] == '=') << 1 |
|
||||
const unsigned padding_pattern = (in[0] == '=') << 3 | //
|
||||
(in[1] == '=') << 2 | //
|
||||
(in[2] == '=') << 1 | //
|
||||
(in[3] == '=');
|
||||
|
||||
// In presence of padding, the lowest bits of v are unused. Canonical encoding
|
||||
// (RFC 4648, section 3.5) requires that these bits all be set to zero. Common
|
||||
// PEM parsers accept noncanonical base64, adding to the malleability of the
|
||||
// format. This decoder follows OpenSSL's and Go's PEM parsers and accepts it.
|
||||
switch (padding_pattern) {
|
||||
case 0:
|
||||
// The common case of no padding.
|
||||
@@ -413,8 +411,7 @@ int EVP_DecodeBase64(uint8_t *out, size_t *out_len, size_t max_out,
|
||||
}
|
||||
|
||||
size_t max_len;
|
||||
if (!EVP_DecodedLength(&max_len, in_len) ||
|
||||
max_out < max_len) {
|
||||
if (!EVP_DecodedLength(&max_len, in_len) || max_out < max_len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -450,7 +447,7 @@ int EVP_DecodeBlock(uint8_t *dst, const uint8_t *src, size_t src_len) {
|
||||
|
||||
// Trim newlines, spaces and tabs from the end of the line.
|
||||
while (src_len > 0) {
|
||||
switch (src[src_len-1]) {
|
||||
switch (src[src_len - 1]) {
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\r':
|
||||
@@ -463,8 +460,7 @@ int EVP_DecodeBlock(uint8_t *dst, const uint8_t *src, size_t src_len) {
|
||||
}
|
||||
|
||||
size_t dst_len;
|
||||
if (!EVP_DecodedLength(&dst_len, src_len) ||
|
||||
dst_len > INT_MAX ||
|
||||
if (!EVP_DecodedLength(&dst_len, src_len) || dst_len > INT_MAX ||
|
||||
!EVP_DecodeBase64(dst, &dst_len, dst_len, src, src_len)) {
|
||||
return -1;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/* Copyright 2024 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||
|
||||
#ifndef OPENSSL_HEADER_CRYPTO_BCM_SUPPORT_H
|
||||
#define OPENSSL_HEADER_CRYPTO_BCM_SUPPORT_H
|
||||
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// Provided by libcrypto, called from BCM
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_LINUX)
|
||||
// On linux we use MADVISE instead of pthread_atfork(), due
|
||||
// to concerns about clone() being used for address space
|
||||
// duplication.
|
||||
#define OPENSSL_FORK_DETECTION
|
||||
#define OPENSSL_FORK_DETECTION_MADVISE
|
||||
#elif defined(OPENSSL_MACOS) || defined(OPENSSL_IOS) || \
|
||||
defined(OPENSSL_OPENBSD) || defined(OPENSSL_FREEBSD)
|
||||
// These platforms may detect address space duplication with pthread_atfork.
|
||||
// iOS doesn't normally allow fork in apps, but it's there.
|
||||
#define OPENSSL_FORK_DETECTION
|
||||
#define OPENSSL_FORK_DETECTION_PTHREAD_ATFORK
|
||||
#elif defined(OPENSSL_WINDOWS) || defined(OPENSSL_TRUSTY) || \
|
||||
defined(__ZEPHYR__) || defined(CROS_EC)
|
||||
// These platforms do not fork.
|
||||
#define OPENSSL_DOES_NOT_FORK
|
||||
#endif
|
||||
|
||||
#if defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE)
|
||||
#define OPENSSL_RAND_DETERMINISTIC
|
||||
#elif defined(OPENSSL_TRUSTY)
|
||||
#define OPENSSL_RAND_TRUSTY
|
||||
#elif defined(OPENSSL_WINDOWS)
|
||||
#define OPENSSL_RAND_WINDOWS
|
||||
#elif defined(OPENSSL_LINUX)
|
||||
#define OPENSSL_RAND_URANDOM
|
||||
#elif defined(OPENSSL_APPLE) && !defined(OPENSSL_MACOS)
|
||||
// Unlike macOS, iOS and similar hide away getentropy().
|
||||
#define OPENSSL_RAND_IOS
|
||||
#else
|
||||
// By default if you are integrating BoringSSL we expect you to
|
||||
// provide getentropy from the <unistd.h> header file.
|
||||
#define OPENSSL_RAND_GETENTROPY
|
||||
#endif
|
||||
|
||||
// Provided by libcrypto, called from BCM
|
||||
|
||||
// CRYPTO_init_sysrand initializes long-lived resources needed to draw entropy
|
||||
// from the operating system, if the operating system requires initialization.
|
||||
void CRYPTO_init_sysrand(void);
|
||||
|
||||
// CRYPTO_sysrand fills |len| bytes at |buf| with entropy from the operating
|
||||
// system.
|
||||
void CRYPTO_sysrand(uint8_t *buf, size_t len);
|
||||
|
||||
// CRYPTO_sysrand_if_available fills |len| bytes at |buf| with entropy from the
|
||||
// operating system, or early /dev/urandom data, and returns 1, _if_ the entropy
|
||||
// pool is initialized or if getrandom() is not available and not in FIPS mode.
|
||||
// Otherwise it will not block and will instead fill |buf| with all zeros and
|
||||
// return 0.
|
||||
int CRYPTO_sysrand_if_available(uint8_t *buf, size_t len);
|
||||
|
||||
// CRYPTO_sysrand_for_seed fills |len| bytes at |buf| with entropy from the
|
||||
// operating system. It may draw from the |GRND_RANDOM| pool on Android,
|
||||
// depending on the vendor's configuration.
|
||||
void CRYPTO_sysrand_for_seed(uint8_t *buf, size_t len);
|
||||
|
||||
// RAND_need_entropy is called whenever the BCM module has stopped because it
|
||||
// has run out of entropy.
|
||||
void RAND_need_entropy(size_t bytes_needed);
|
||||
|
||||
// crypto_get_fork_generation returns the fork generation number for the current
|
||||
// process, or zero if not supported on the platform. The fork generation number
|
||||
// is a non-zero, strictly-monotonic counter with the property that, if queried
|
||||
// in an address space and then again in a subsequently forked copy, the forked
|
||||
// address space will observe a greater value.
|
||||
//
|
||||
// This function may be used to clear cached values across a fork. When
|
||||
// initializing a cache, record the fork generation. Before using the cache,
|
||||
// check if the fork generation has changed. If so, drop the cache and update
|
||||
// the save fork generation. Note this logic transparently handles platforms
|
||||
// which always return zero.
|
||||
//
|
||||
// This is not reliably supported on all platforms which implement |fork|, so it
|
||||
// should only be used as a hardening measure.
|
||||
OPENSSL_EXPORT uint64_t CRYPTO_get_fork_generation(void);
|
||||
|
||||
// CRYPTO_fork_detect_force_madv_wipeonfork_for_testing is an internal detail
|
||||
// used for testing purposes.
|
||||
OPENSSL_EXPORT void CRYPTO_fork_detect_force_madv_wipeonfork_for_testing(
|
||||
int on);
|
||||
|
||||
// CRYPTO_get_stderr returns stderr. This function exists to avoid BCM needing
|
||||
// a data dependency on libc.
|
||||
FILE *CRYPTO_get_stderr(void);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern C
|
||||
#endif
|
||||
|
||||
#endif // OPENSSL_HEADER_CRYPTO_BCM_SUPPORT_H
|
||||
+60
-68
@@ -69,16 +69,19 @@
|
||||
#include "../internal.h"
|
||||
|
||||
|
||||
static CRYPTO_EX_DATA_CLASS g_ex_data_class =
|
||||
CRYPTO_EX_DATA_CLASS_INIT_WITH_APP_DATA;
|
||||
|
||||
BIO *BIO_new(const BIO_METHOD *method) {
|
||||
BIO *ret = OPENSSL_malloc(sizeof(BIO));
|
||||
BIO *ret = reinterpret_cast<BIO *>(OPENSSL_zalloc(sizeof(BIO)));
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OPENSSL_memset(ret, 0, sizeof(BIO));
|
||||
ret->method = method;
|
||||
ret->shutdown = 1;
|
||||
ret->references = 1;
|
||||
CRYPTO_new_ex_data(&ret->ex_data);
|
||||
|
||||
if (method->create != NULL && !method->create(ret)) {
|
||||
OPENSSL_free(ret);
|
||||
@@ -102,6 +105,7 @@ int BIO_free(BIO *bio) {
|
||||
bio->method->destroy(bio);
|
||||
}
|
||||
|
||||
CRYPTO_free_ex_data(&g_ex_data_class, bio, &bio->ex_data);
|
||||
OPENSSL_free(bio);
|
||||
}
|
||||
return 1;
|
||||
@@ -112,13 +116,9 @@ int BIO_up_ref(BIO *bio) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void BIO_vfree(BIO *bio) {
|
||||
BIO_free(bio);
|
||||
}
|
||||
void BIO_vfree(BIO *bio) { BIO_free(bio); }
|
||||
|
||||
void BIO_free_all(BIO *bio) {
|
||||
BIO_free(bio);
|
||||
}
|
||||
void BIO_free_all(BIO *bio) { BIO_free(bio); }
|
||||
|
||||
int BIO_read(BIO *bio, void *buf, int len) {
|
||||
if (bio == NULL || bio->method == NULL || bio->method->bread == NULL) {
|
||||
@@ -132,7 +132,7 @@ int BIO_read(BIO *bio, void *buf, int len) {
|
||||
if (len <= 0) {
|
||||
return 0;
|
||||
}
|
||||
int ret = bio->method->bread(bio, buf, len);
|
||||
int ret = bio->method->bread(bio, reinterpret_cast<char *>(buf), len);
|
||||
if (ret > 0) {
|
||||
bio->num_read += ret;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ int BIO_write(BIO *bio, const void *in, int inl) {
|
||||
if (inl <= 0) {
|
||||
return 0;
|
||||
}
|
||||
int ret = bio->method->bwrite(bio, in, inl);
|
||||
int ret = bio->method->bwrite(bio, reinterpret_cast<const char *>(in), inl);
|
||||
if (ret > 0) {
|
||||
bio->num_write += ret;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ int BIO_write(BIO *bio, const void *in, int inl) {
|
||||
}
|
||||
|
||||
int BIO_write_all(BIO *bio, const void *data, size_t len) {
|
||||
const uint8_t *data_u8 = data;
|
||||
const uint8_t *data_u8 = reinterpret_cast<const uint8_t *>(data);
|
||||
while (len > 0) {
|
||||
int ret = BIO_write(bio, data_u8, len > INT_MAX ? INT_MAX : (int)len);
|
||||
if (ret <= 0) {
|
||||
@@ -200,9 +200,7 @@ int BIO_puts(BIO *bio, const char *in) {
|
||||
return BIO_write(bio, in, (int)len);
|
||||
}
|
||||
|
||||
int BIO_flush(BIO *bio) {
|
||||
return (int)BIO_ctrl(bio, BIO_CTRL_FLUSH, 0, NULL);
|
||||
}
|
||||
int BIO_flush(BIO *bio) { return (int)BIO_ctrl(bio, BIO_CTRL_FLUSH, 0, NULL); }
|
||||
|
||||
long BIO_ctrl(BIO *bio, int cmd, long larg, void *parg) {
|
||||
if (bio == NULL) {
|
||||
@@ -233,21 +231,13 @@ long BIO_int_ctrl(BIO *b, int cmd, long larg, int iarg) {
|
||||
return BIO_ctrl(b, cmd, larg, (void *)&i);
|
||||
}
|
||||
|
||||
int BIO_reset(BIO *bio) {
|
||||
return (int)BIO_ctrl(bio, BIO_CTRL_RESET, 0, NULL);
|
||||
}
|
||||
int BIO_reset(BIO *bio) { return (int)BIO_ctrl(bio, BIO_CTRL_RESET, 0, NULL); }
|
||||
|
||||
int BIO_eof(BIO *bio) {
|
||||
return (int)BIO_ctrl(bio, BIO_CTRL_EOF, 0, NULL);
|
||||
}
|
||||
int BIO_eof(BIO *bio) { return (int)BIO_ctrl(bio, BIO_CTRL_EOF, 0, NULL); }
|
||||
|
||||
void BIO_set_flags(BIO *bio, int flags) {
|
||||
bio->flags |= flags;
|
||||
}
|
||||
void BIO_set_flags(BIO *bio, int flags) { bio->flags |= flags; }
|
||||
|
||||
int BIO_test_flags(const BIO *bio, int flags) {
|
||||
return bio->flags & flags;
|
||||
}
|
||||
int BIO_test_flags(const BIO *bio, int flags) { return bio->flags & flags; }
|
||||
|
||||
int BIO_should_read(const BIO *bio) {
|
||||
return BIO_test_flags(bio, BIO_FLAGS_READ);
|
||||
@@ -269,9 +259,7 @@ int BIO_get_retry_reason(const BIO *bio) { return bio->retry_reason; }
|
||||
|
||||
void BIO_set_retry_reason(BIO *bio, int reason) { bio->retry_reason = reason; }
|
||||
|
||||
void BIO_clear_flags(BIO *bio, int flags) {
|
||||
bio->flags &= ~flags;
|
||||
}
|
||||
void BIO_clear_flags(BIO *bio, int flags) { bio->flags &= ~flags; }
|
||||
|
||||
void BIO_set_retry_read(BIO *bio) {
|
||||
bio->flags |= BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY;
|
||||
@@ -283,9 +271,7 @@ void BIO_set_retry_write(BIO *bio) {
|
||||
|
||||
static const int kRetryFlags = BIO_FLAGS_RWS | BIO_FLAGS_SHOULD_RETRY;
|
||||
|
||||
int BIO_get_retry_flags(BIO *bio) {
|
||||
return bio->flags & kRetryFlags;
|
||||
}
|
||||
int BIO_get_retry_flags(BIO *bio) { return bio->flags & kRetryFlags; }
|
||||
|
||||
void BIO_clear_retry_flags(BIO *bio) {
|
||||
bio->flags &= ~kRetryFlags;
|
||||
@@ -314,7 +300,7 @@ long BIO_callback_ctrl(BIO *bio, int cmd, bio_info_cb fp) {
|
||||
}
|
||||
|
||||
size_t BIO_pending(const BIO *bio) {
|
||||
const long r = BIO_ctrl((BIO *) bio, BIO_CTRL_PENDING, 0, NULL);
|
||||
const long r = BIO_ctrl((BIO *)bio, BIO_CTRL_PENDING, 0, NULL);
|
||||
assert(r >= 0);
|
||||
|
||||
if (r < 0) {
|
||||
@@ -323,12 +309,10 @@ size_t BIO_pending(const BIO *bio) {
|
||||
return r;
|
||||
}
|
||||
|
||||
size_t BIO_ctrl_pending(const BIO *bio) {
|
||||
return BIO_pending(bio);
|
||||
}
|
||||
size_t BIO_ctrl_pending(const BIO *bio) { return BIO_pending(bio); }
|
||||
|
||||
size_t BIO_wpending(const BIO *bio) {
|
||||
const long r = BIO_ctrl((BIO *) bio, BIO_CTRL_WPENDING, 0, NULL);
|
||||
const long r = BIO_ctrl((BIO *)bio, BIO_CTRL_WPENDING, 0, NULL);
|
||||
assert(r >= 0);
|
||||
|
||||
if (r < 0) {
|
||||
@@ -341,11 +325,11 @@ int BIO_set_close(BIO *bio, int close_flag) {
|
||||
return (int)BIO_ctrl(bio, BIO_CTRL_SET_CLOSE, close_flag, NULL);
|
||||
}
|
||||
|
||||
OPENSSL_EXPORT size_t BIO_number_read(const BIO *bio) {
|
||||
OPENSSL_EXPORT uint64_t BIO_number_read(const BIO *bio) {
|
||||
return bio->num_read;
|
||||
}
|
||||
|
||||
OPENSSL_EXPORT size_t BIO_number_written(const BIO *bio) {
|
||||
OPENSSL_EXPORT uint64_t BIO_number_written(const BIO *bio) {
|
||||
return bio->num_write;
|
||||
}
|
||||
|
||||
@@ -426,9 +410,7 @@ static int print_bio(const char *str, size_t len, void *bio) {
|
||||
return BIO_write_all((BIO *)bio, str, len);
|
||||
}
|
||||
|
||||
void ERR_print_errors(BIO *bio) {
|
||||
ERR_print_errors_cb(print_bio, bio);
|
||||
}
|
||||
void ERR_print_errors(BIO *bio) { ERR_print_errors_cb(print_bio, bio); }
|
||||
|
||||
// bio_read_all reads everything from |bio| and prepends |prefix| to it. On
|
||||
// success, |*out| is set to an allocated buffer (which should be freed with
|
||||
@@ -450,7 +432,7 @@ static int bio_read_all(BIO *bio, uint8_t **out, size_t *out_len,
|
||||
if (len < prefix_len) {
|
||||
return 0;
|
||||
}
|
||||
*out = OPENSSL_malloc(len);
|
||||
*out = reinterpret_cast<uint8_t *>(OPENSSL_malloc(len));
|
||||
if (*out == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -481,7 +463,8 @@ static int bio_read_all(BIO *bio, uint8_t **out, size_t *out_len,
|
||||
if (len < kChunkSize || len > max_len) {
|
||||
len = max_len;
|
||||
}
|
||||
uint8_t *new_buf = OPENSSL_realloc(*out, len);
|
||||
uint8_t *new_buf =
|
||||
reinterpret_cast<uint8_t *>(OPENSSL_realloc(*out, len));
|
||||
if (new_buf == NULL) {
|
||||
OPENSSL_free(*out);
|
||||
return 0;
|
||||
@@ -590,7 +573,7 @@ int BIO_read_asn1(BIO *bio, uint8_t **out, size_t *out_len, size_t max_len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((len32 >> ((num_bytes-1)*8)) == 0) {
|
||||
if ((len32 >> ((num_bytes - 1) * 8)) == 0) {
|
||||
// Length should have been at least one byte shorter.
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
|
||||
return 0;
|
||||
@@ -599,16 +582,14 @@ int BIO_read_asn1(BIO *bio, uint8_t **out, size_t *out_len, size_t max_len) {
|
||||
len = len32;
|
||||
}
|
||||
|
||||
if (len + header_len < len ||
|
||||
len + header_len > max_len ||
|
||||
len > INT_MAX) {
|
||||
if (len + header_len < len || len + header_len > max_len || len > INT_MAX) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TOO_LONG);
|
||||
return 0;
|
||||
}
|
||||
len += header_len;
|
||||
*out_len = len;
|
||||
|
||||
*out = OPENSSL_malloc(len);
|
||||
*out = reinterpret_cast<uint8_t *>(OPENSSL_malloc(len));
|
||||
if (*out == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -640,53 +621,49 @@ int BIO_get_new_index(void) {
|
||||
}
|
||||
|
||||
BIO_METHOD *BIO_meth_new(int type, const char *name) {
|
||||
BIO_METHOD *method = OPENSSL_malloc(sizeof(BIO_METHOD));
|
||||
BIO_METHOD *method =
|
||||
reinterpret_cast<BIO_METHOD *>(OPENSSL_zalloc(sizeof(BIO_METHOD)));
|
||||
if (method == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
OPENSSL_memset(method, 0, sizeof(BIO_METHOD));
|
||||
method->type = type;
|
||||
method->name = name;
|
||||
return method;
|
||||
}
|
||||
|
||||
void BIO_meth_free(BIO_METHOD *method) {
|
||||
OPENSSL_free(method);
|
||||
}
|
||||
void BIO_meth_free(BIO_METHOD *method) { OPENSSL_free(method); }
|
||||
|
||||
int BIO_meth_set_create(BIO_METHOD *method,
|
||||
int (*create)(BIO *)) {
|
||||
method->create = create;
|
||||
int BIO_meth_set_create(BIO_METHOD *method, int (*create_func)(BIO *)) {
|
||||
method->create = create_func;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int BIO_meth_set_destroy(BIO_METHOD *method,
|
||||
int (*destroy)(BIO *)) {
|
||||
method->destroy = destroy;
|
||||
int BIO_meth_set_destroy(BIO_METHOD *method, int (*destroy_func)(BIO *)) {
|
||||
method->destroy = destroy_func;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int BIO_meth_set_write(BIO_METHOD *method,
|
||||
int (*write)(BIO *, const char *, int)) {
|
||||
method->bwrite = write;
|
||||
int (*write_func)(BIO *, const char *, int)) {
|
||||
method->bwrite = write_func;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int BIO_meth_set_read(BIO_METHOD *method,
|
||||
int (*read)(BIO *, char *, int)) {
|
||||
method->bread = read;
|
||||
int (*read_func)(BIO *, char *, int)) {
|
||||
method->bread = read_func;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int BIO_meth_set_gets(BIO_METHOD *method,
|
||||
int (*gets)(BIO *, char *, int)) {
|
||||
method->bgets = gets;
|
||||
int (*gets_func)(BIO *, char *, int)) {
|
||||
method->bgets = gets_func;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int BIO_meth_set_ctrl(BIO_METHOD *method,
|
||||
long (*ctrl)(BIO *, int, long, void *)) {
|
||||
method->ctrl = ctrl;
|
||||
long (*ctrl_func)(BIO *, int, long, void *)) {
|
||||
method->ctrl = ctrl_func;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -706,3 +683,18 @@ int BIO_meth_set_puts(BIO_METHOD *method, int (*puts)(BIO *, const char *)) {
|
||||
// Ignore the parameter. We implement |BIO_puts| using |BIO_write|.
|
||||
return 1;
|
||||
}
|
||||
|
||||
int BIO_get_ex_new_index(long argl, void *argp, //
|
||||
CRYPTO_EX_unused *unused, //
|
||||
CRYPTO_EX_dup *dup_unused, //
|
||||
CRYPTO_EX_free *free_func) {
|
||||
return CRYPTO_get_ex_new_index_ex(&g_ex_data_class, argl, argp, free_func);
|
||||
}
|
||||
|
||||
int BIO_set_ex_data(BIO *bio, int idx, void *data) {
|
||||
return CRYPTO_set_ex_data(&bio->ex_data, idx, data);
|
||||
}
|
||||
|
||||
void *BIO_get_ex_data(const BIO *bio, int idx) {
|
||||
return CRYPTO_get_ex_data(&bio->ex_data, idx);
|
||||
}
|
||||
+8
-7
@@ -83,7 +83,7 @@ BIO *BIO_new_mem_buf(const void *buf, ossl_ssize_t len) {
|
||||
|
||||
b = (BUF_MEM *)ret->ptr;
|
||||
// BIO_FLAGS_MEM_RDONLY ensures |b->data| is not written to.
|
||||
b->data = (void *)buf;
|
||||
b->data = reinterpret_cast<char *>(const_cast<void *>(buf));
|
||||
b->length = size;
|
||||
b->max = size;
|
||||
|
||||
@@ -135,7 +135,7 @@ static int mem_read(BIO *bio, char *out, int outl) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
BUF_MEM *b = bio->ptr;
|
||||
BUF_MEM *b = reinterpret_cast<BUF_MEM *>(bio->ptr);
|
||||
int ret = outl;
|
||||
if ((size_t)ret > b->length) {
|
||||
ret = (int)b->length;
|
||||
@@ -169,7 +169,7 @@ static int mem_write(BIO *bio, const char *in, int inl) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
BUF_MEM *b = bio->ptr;
|
||||
BUF_MEM *b = reinterpret_cast<BUF_MEM *>(bio->ptr);
|
||||
if (!BUF_MEM_append(b, in, inl)) {
|
||||
return -1;
|
||||
}
|
||||
@@ -185,14 +185,15 @@ static int mem_gets(BIO *bio, char *buf, int size) {
|
||||
|
||||
// The buffer size includes space for the trailing NUL, so we can read at most
|
||||
// one fewer byte.
|
||||
BUF_MEM *b = bio->ptr;
|
||||
BUF_MEM *b = reinterpret_cast<BUF_MEM *>(bio->ptr);
|
||||
int ret = size - 1;
|
||||
if ((size_t)ret > b->length) {
|
||||
ret = (int)b->length;
|
||||
}
|
||||
|
||||
// Stop at the first newline.
|
||||
const char *newline = OPENSSL_memchr(b->data, '\n', ret);
|
||||
const char *newline =
|
||||
reinterpret_cast<char *>(OPENSSL_memchr(b->data, '\n', ret));
|
||||
if (newline != NULL) {
|
||||
ret = (int)(newline - b->data + 1);
|
||||
}
|
||||
@@ -231,7 +232,7 @@ static long mem_ctrl(BIO *bio, int cmd, long num, void *ptr) {
|
||||
case BIO_CTRL_INFO:
|
||||
ret = (long)b->length;
|
||||
if (ptr != NULL) {
|
||||
char **pptr = ptr;
|
||||
char **pptr = reinterpret_cast<char **>(ptr);
|
||||
*pptr = b->data;
|
||||
}
|
||||
break;
|
||||
@@ -242,7 +243,7 @@ static long mem_ctrl(BIO *bio, int cmd, long num, void *ptr) {
|
||||
break;
|
||||
case BIO_C_GET_BUF_MEM_PTR:
|
||||
if (ptr != NULL) {
|
||||
BUF_MEM **pptr = ptr;
|
||||
BUF_MEM **pptr = reinterpret_cast<BUF_MEM **>(ptr);
|
||||
*pptr = b;
|
||||
}
|
||||
break;
|
||||
+24
-19
@@ -63,9 +63,9 @@
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(OPENSSL_WINDOWS)
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#else
|
||||
OPENSSL_MSVC_PRAGMA(warning(push, 3))
|
||||
@@ -77,8 +77,8 @@ OPENSSL_MSVC_PRAGMA(warning(pop))
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "../internal.h"
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
enum {
|
||||
@@ -109,9 +109,7 @@ typedef struct bio_connect_st {
|
||||
} BIO_CONNECT;
|
||||
|
||||
#if !defined(OPENSSL_WINDOWS)
|
||||
static int closesocket(int sock) {
|
||||
return close(sock);
|
||||
}
|
||||
static int closesocket(int sock) { return close(sock); }
|
||||
#endif
|
||||
|
||||
// split_host_and_port sets |*out_host| and |*out_port| to the host and port
|
||||
@@ -231,7 +229,7 @@ static int conn_state(BIO *bio, BIO_CONNECT *c) {
|
||||
}
|
||||
|
||||
BIO_clear_retry_flags(bio);
|
||||
ret = connect(bio->num, (struct sockaddr*) &c->them, c->them_length);
|
||||
ret = connect(bio->num, (struct sockaddr *)&c->them, c->them_length);
|
||||
if (ret < 0) {
|
||||
if (bio_socket_should_retry(ret)) {
|
||||
BIO_set_flags(bio, (BIO_FLAGS_IO_SPECIAL | BIO_FLAGS_SHOULD_RETRY));
|
||||
@@ -261,7 +259,8 @@ static int conn_state(BIO *bio, BIO_CONNECT *c) {
|
||||
BIO_clear_retry_flags(bio);
|
||||
OPENSSL_PUT_SYSTEM_ERROR();
|
||||
OPENSSL_PUT_ERROR(BIO, BIO_R_NBIO_CONNECT_ERROR);
|
||||
ERR_add_error_data(4, "host=", c->param_hostname, ":", c->param_port);
|
||||
ERR_add_error_data(4, "host=", c->param_hostname, ":",
|
||||
c->param_port);
|
||||
ret = 0;
|
||||
}
|
||||
goto exit_loop;
|
||||
@@ -296,13 +295,11 @@ end:
|
||||
}
|
||||
|
||||
static BIO_CONNECT *BIO_CONNECT_new(void) {
|
||||
BIO_CONNECT *ret = OPENSSL_malloc(sizeof(BIO_CONNECT));
|
||||
|
||||
BIO_CONNECT *ret =
|
||||
reinterpret_cast<BIO_CONNECT *>(OPENSSL_zalloc(sizeof(BIO_CONNECT)));
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
OPENSSL_memset(ret, 0, sizeof(BIO_CONNECT));
|
||||
|
||||
ret->state = BIO_CONN_S_BEFORE;
|
||||
return ret;
|
||||
}
|
||||
@@ -326,7 +323,7 @@ static int conn_new(BIO *bio) {
|
||||
}
|
||||
|
||||
static void conn_close_socket(BIO *bio) {
|
||||
BIO_CONNECT *c = (BIO_CONNECT *) bio->ptr;
|
||||
BIO_CONNECT *c = (BIO_CONNECT *)bio->ptr;
|
||||
|
||||
if (bio->num == -1) {
|
||||
return;
|
||||
@@ -345,7 +342,7 @@ static int conn_free(BIO *bio) {
|
||||
conn_close_socket(bio);
|
||||
}
|
||||
|
||||
BIO_CONNECT_free((BIO_CONNECT*) bio->ptr);
|
||||
BIO_CONNECT_free((BIO_CONNECT *)bio->ptr);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -425,13 +422,15 @@ static long conn_ctrl(BIO *bio, int cmd, long num, void *ptr) {
|
||||
bio->init = 1;
|
||||
if (num == 0) {
|
||||
OPENSSL_free(data->param_hostname);
|
||||
data->param_hostname = OPENSSL_strdup(ptr);
|
||||
data->param_hostname =
|
||||
OPENSSL_strdup(reinterpret_cast<const char *>(ptr));
|
||||
if (data->param_hostname == NULL) {
|
||||
ret = 0;
|
||||
}
|
||||
} else if (num == 1) {
|
||||
OPENSSL_free(data->param_port);
|
||||
data->param_port = OPENSSL_strdup(ptr);
|
||||
data->param_port =
|
||||
OPENSSL_strdup(reinterpret_cast<const char *>(ptr));
|
||||
if (data->param_port == NULL) {
|
||||
ret = 0;
|
||||
}
|
||||
@@ -467,7 +466,8 @@ static long conn_ctrl(BIO *bio, int cmd, long num, void *ptr) {
|
||||
case BIO_CTRL_FLUSH:
|
||||
break;
|
||||
case BIO_CTRL_GET_CALLBACK: {
|
||||
int (**fptr)(const BIO *bio, int state, int xret) = ptr;
|
||||
int (**fptr)(const BIO *bio, int state, int xret);
|
||||
fptr = reinterpret_cast<decltype(fptr)>(ptr);
|
||||
*fptr = data->info_callback;
|
||||
} break;
|
||||
default:
|
||||
@@ -490,7 +490,12 @@ static long conn_callback_ctrl(BIO *bio, int cmd, bio_info_cb fp) {
|
||||
// convention.
|
||||
OPENSSL_MSVC_PRAGMA(warning(push))
|
||||
OPENSSL_MSVC_PRAGMA(warning(disable : 4191))
|
||||
OPENSSL_CLANG_PRAGMA("clang diagnostic push")
|
||||
OPENSSL_CLANG_PRAGMA(
|
||||
"clang diagnostic ignored \"-Wunknown-warning-option\"")
|
||||
OPENSSL_CLANG_PRAGMA("clang diagnostic ignored \"-Wcast-function-type\"")
|
||||
data->info_callback = (int (*)(const struct bio_st *, int, int))fp;
|
||||
OPENSSL_CLANG_PRAGMA("clang diagnostic pop")
|
||||
OPENSSL_MSVC_PRAGMA(warning(pop))
|
||||
break;
|
||||
default:
|
||||
@@ -523,11 +528,11 @@ static const BIO_METHOD methods_connectp = {
|
||||
const BIO_METHOD *BIO_s_connect(void) { return &methods_connectp; }
|
||||
|
||||
int BIO_set_conn_hostname(BIO *bio, const char *name) {
|
||||
return (int)BIO_ctrl(bio, BIO_C_SET_CONNECT, 0, (void*) name);
|
||||
return (int)BIO_ctrl(bio, BIO_C_SET_CONNECT, 0, (void *)name);
|
||||
}
|
||||
|
||||
int BIO_set_conn_port(BIO *bio, const char *port_str) {
|
||||
return (int)BIO_ctrl(bio, BIO_C_SET_CONNECT, 1, (void*) port_str);
|
||||
return (int)BIO_ctrl(bio, BIO_C_SET_CONNECT, 1, (void *)port_str);
|
||||
}
|
||||
|
||||
int BIO_set_conn_int_port(BIO *bio, const int *port) {
|
||||
File renamed without changes.
File renamed without changes.
+27
-12
@@ -73,6 +73,7 @@
|
||||
|
||||
#include <CCryptoBoringSSL_bio.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -82,6 +83,10 @@
|
||||
|
||||
#include "../internal.h"
|
||||
|
||||
#if defined(OPENSSL_WINDOWS)
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#define BIO_FP_READ 0x02
|
||||
#define BIO_FP_WRITE 0x04
|
||||
@@ -122,14 +127,13 @@ BIO *BIO_new_file(const char *filename, const char *mode) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
BIO *BIO_new_fp(FILE *stream, int close_flag) {
|
||||
BIO *BIO_new_fp(FILE *stream, int flags) {
|
||||
BIO *ret = BIO_new(BIO_s_file());
|
||||
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BIO_set_fp(ret, stream, close_flag);
|
||||
BIO_set_fp(ret, stream, flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -139,7 +143,7 @@ static int file_free(BIO *bio) {
|
||||
}
|
||||
|
||||
if (bio->init && bio->ptr != NULL) {
|
||||
fclose(bio->ptr);
|
||||
fclose(reinterpret_cast<FILE *>(bio->ptr));
|
||||
bio->ptr = NULL;
|
||||
}
|
||||
bio->init = 0;
|
||||
@@ -196,6 +200,17 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) {
|
||||
break;
|
||||
case BIO_C_SET_FILE_PTR:
|
||||
file_free(b);
|
||||
static_assert((BIO_CLOSE & BIO_FP_TEXT) == 0,
|
||||
"BIO_CLOSE and BIO_FP_TEXT must not collide");
|
||||
#if defined(OPENSSL_WINDOWS)
|
||||
// If |BIO_FP_TEXT| is not set, OpenSSL will switch the file to binary
|
||||
// mode. BoringSSL intentionally diverges here because it means code
|
||||
// tested under POSIX will inadvertently change the state of |FILE|
|
||||
// objects when wrapping them in a |BIO|.
|
||||
if (num & BIO_FP_TEXT) {
|
||||
_setmode(_fileno(reinterpret_cast<FILE *>(ptr)), _O_TEXT);
|
||||
}
|
||||
#endif
|
||||
b->shutdown = (int)num & BIO_CLOSE;
|
||||
b->ptr = ptr;
|
||||
b->init = 1;
|
||||
@@ -206,22 +221,22 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) {
|
||||
const char *mode;
|
||||
if (num & BIO_FP_APPEND) {
|
||||
if (num & BIO_FP_READ) {
|
||||
mode = "a+";
|
||||
mode = "ab+";
|
||||
} else {
|
||||
mode = "a";
|
||||
mode = "ab";
|
||||
}
|
||||
} else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE)) {
|
||||
mode = "r+";
|
||||
mode = "rb+";
|
||||
} else if (num & BIO_FP_WRITE) {
|
||||
mode = "w";
|
||||
mode = "wb";
|
||||
} else if (num & BIO_FP_READ) {
|
||||
mode = "r";
|
||||
mode = "rb";
|
||||
} else {
|
||||
OPENSSL_PUT_ERROR(BIO, BIO_R_BAD_FOPEN_MODE);
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
fp = fopen_if_available(ptr, mode);
|
||||
fp = fopen_if_available(reinterpret_cast<const char *>(ptr), mode);
|
||||
if (fp == NULL) {
|
||||
OPENSSL_PUT_SYSTEM_ERROR();
|
||||
ERR_add_error_data(5, "fopen('", ptr, "','", mode, "')");
|
||||
@@ -287,8 +302,8 @@ int BIO_get_fp(BIO *bio, FILE **out_file) {
|
||||
return (int)BIO_ctrl(bio, BIO_C_GET_FILE_PTR, 0, (char *)out_file);
|
||||
}
|
||||
|
||||
int BIO_set_fp(BIO *bio, FILE *file, int close_flag) {
|
||||
return (int)BIO_ctrl(bio, BIO_C_SET_FILE_PTR, close_flag, (char *)file);
|
||||
int BIO_set_fp(BIO *bio, FILE *file, int flags) {
|
||||
return (int)BIO_ctrl(bio, BIO_C_SET_FILE_PTR, flags, (char *)file);
|
||||
}
|
||||
|
||||
int BIO_read_filename(BIO *bio, const char *filename) {
|
||||
File renamed without changes.
+22
-23
@@ -81,13 +81,11 @@ struct bio_bio_st {
|
||||
};
|
||||
|
||||
static int bio_new(BIO *bio) {
|
||||
struct bio_bio_st *b;
|
||||
|
||||
b = OPENSSL_malloc(sizeof *b);
|
||||
struct bio_bio_st *b =
|
||||
reinterpret_cast<bio_bio_st *>(OPENSSL_zalloc(sizeof *b));
|
||||
if (b == NULL) {
|
||||
return 0;
|
||||
}
|
||||
OPENSSL_memset(b, 0, sizeof(struct bio_bio_st));
|
||||
|
||||
b->size = 17 * 1024; // enough for one TLS record (just a default)
|
||||
bio->ptr = b;
|
||||
@@ -95,7 +93,7 @@ static int bio_new(BIO *bio) {
|
||||
}
|
||||
|
||||
static void bio_destroy_pair(BIO *bio) {
|
||||
struct bio_bio_st *b = bio->ptr;
|
||||
struct bio_bio_st *b = reinterpret_cast<bio_bio_st *>(bio->ptr);
|
||||
BIO *peer_bio;
|
||||
struct bio_bio_st *peer_b;
|
||||
|
||||
@@ -108,7 +106,7 @@ static void bio_destroy_pair(BIO *bio) {
|
||||
return;
|
||||
}
|
||||
|
||||
peer_b = peer_bio->ptr;
|
||||
peer_b = reinterpret_cast<bio_bio_st *>(peer_bio->ptr);
|
||||
|
||||
assert(peer_b != NULL);
|
||||
assert(peer_b->peer == bio);
|
||||
@@ -127,7 +125,7 @@ static void bio_destroy_pair(BIO *bio) {
|
||||
}
|
||||
|
||||
static int bio_free(BIO *bio) {
|
||||
struct bio_bio_st *b = bio->ptr;
|
||||
struct bio_bio_st *b = reinterpret_cast<bio_bio_st *>(bio->ptr);
|
||||
|
||||
assert(b != NULL);
|
||||
|
||||
@@ -152,10 +150,10 @@ static int bio_read(BIO *bio, char *buf, int size_) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = bio->ptr;
|
||||
b = reinterpret_cast<bio_bio_st *>(bio->ptr);
|
||||
assert(b != NULL);
|
||||
assert(b->peer != NULL);
|
||||
peer_b = b->peer->ptr;
|
||||
peer_b = reinterpret_cast<bio_bio_st *>(b->peer->ptr);
|
||||
assert(peer_b != NULL);
|
||||
assert(peer_b->buf != NULL);
|
||||
|
||||
@@ -236,7 +234,7 @@ static int bio_write(BIO *bio, const char *buf, int num_) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = bio->ptr;
|
||||
b = reinterpret_cast<bio_bio_st *>(bio->ptr);
|
||||
assert(b != NULL);
|
||||
assert(b->peer != NULL);
|
||||
assert(b->buf != NULL);
|
||||
@@ -305,8 +303,8 @@ static int bio_make_pair(BIO *bio1, BIO *bio2, size_t writebuf1_len,
|
||||
assert(bio1 != NULL);
|
||||
assert(bio2 != NULL);
|
||||
|
||||
b1 = bio1->ptr;
|
||||
b2 = bio2->ptr;
|
||||
b1 = reinterpret_cast<bio_bio_st *>(bio1->ptr);
|
||||
b2 = reinterpret_cast<bio_bio_st *>(bio2->ptr);
|
||||
|
||||
if (b1->peer != NULL || b2->peer != NULL) {
|
||||
OPENSSL_PUT_ERROR(BIO, BIO_R_IN_USE);
|
||||
@@ -317,7 +315,7 @@ static int bio_make_pair(BIO *bio1, BIO *bio2, size_t writebuf1_len,
|
||||
if (writebuf1_len) {
|
||||
b1->size = writebuf1_len;
|
||||
}
|
||||
b1->buf = OPENSSL_malloc(b1->size);
|
||||
b1->buf = reinterpret_cast<uint8_t *>(OPENSSL_malloc(b1->size));
|
||||
if (b1->buf == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -329,7 +327,7 @@ static int bio_make_pair(BIO *bio1, BIO *bio2, size_t writebuf1_len,
|
||||
if (writebuf2_len) {
|
||||
b2->size = writebuf2_len;
|
||||
}
|
||||
b2->buf = OPENSSL_malloc(b2->size);
|
||||
b2->buf = reinterpret_cast<uint8_t *>(OPENSSL_malloc(b2->size));
|
||||
if (b2->buf == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -352,13 +350,12 @@ static int bio_make_pair(BIO *bio1, BIO *bio2, size_t writebuf1_len,
|
||||
|
||||
static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr) {
|
||||
long ret;
|
||||
struct bio_bio_st *b = bio->ptr;
|
||||
struct bio_bio_st *b = reinterpret_cast<bio_bio_st *>(bio->ptr);
|
||||
|
||||
assert(b != NULL);
|
||||
|
||||
switch (cmd) {
|
||||
// specific CTRL codes
|
||||
|
||||
// Specific control codes first:
|
||||
case BIO_C_GET_WRITE_BUF_SIZE:
|
||||
ret = (long)b->size;
|
||||
break;
|
||||
@@ -395,8 +392,8 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr) {
|
||||
ret = 1;
|
||||
break;
|
||||
|
||||
// standard CTRL codes follow
|
||||
|
||||
// Standard control codes:
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret = bio->shutdown;
|
||||
break;
|
||||
@@ -408,7 +405,8 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr) {
|
||||
|
||||
case BIO_CTRL_PENDING:
|
||||
if (b->peer != NULL) {
|
||||
struct bio_bio_st *peer_b = b->peer->ptr;
|
||||
struct bio_bio_st *peer_b =
|
||||
reinterpret_cast<bio_bio_st *>(b->peer->ptr);
|
||||
ret = (long)peer_b->len;
|
||||
} else {
|
||||
ret = 0;
|
||||
@@ -427,10 +425,11 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr) {
|
||||
break;
|
||||
|
||||
case BIO_CTRL_EOF: {
|
||||
BIO *other_bio = ptr;
|
||||
BIO *other_bio = reinterpret_cast<BIO *>(ptr);
|
||||
|
||||
if (other_bio) {
|
||||
struct bio_bio_st *other_b = other_bio->ptr;
|
||||
struct bio_bio_st *other_b =
|
||||
reinterpret_cast<bio_bio_st *>(other_bio->ptr);
|
||||
assert(other_b != NULL);
|
||||
ret = other_b->len == 0 && other_b->closed;
|
||||
} else {
|
||||
@@ -452,8 +451,8 @@ static const BIO_METHOD methods_biop = {
|
||||
|
||||
static const BIO_METHOD *bio_s_bio(void) { return &methods_biop; }
|
||||
|
||||
int BIO_new_bio_pair(BIO** bio1_p, size_t writebuf1_len,
|
||||
BIO** bio2_p, size_t writebuf2_len) {
|
||||
int BIO_new_bio_pair(BIO **bio1_p, size_t writebuf1_len, BIO **bio2_p,
|
||||
size_t writebuf2_len) {
|
||||
BIO *bio1 = BIO_new(bio_s_bio());
|
||||
BIO *bio2 = BIO_new(bio_s_bio());
|
||||
if (bio1 == NULL || bio2 == NULL ||
|
||||
+2
-2
@@ -75,12 +75,12 @@ int BIO_printf(BIO *bio, const char *format, ...) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((size_t) out_len >= sizeof(buf)) {
|
||||
if ((size_t)out_len >= sizeof(buf)) {
|
||||
const int requested_len = out_len;
|
||||
// The output was truncated. Note that vsnprintf's return value
|
||||
// does not include a trailing NUL, but the buffer must be sized
|
||||
// for it.
|
||||
out = OPENSSL_malloc(requested_len + 1);
|
||||
out = reinterpret_cast<char *>(OPENSSL_malloc(requested_len + 1));
|
||||
out_malloced = 1;
|
||||
if (out == NULL) {
|
||||
return -1;
|
||||
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2014, Google Inc.
|
||||
/* Copyright 2014 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2021, Google Inc.
|
||||
/* Copyright 2021 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -121,7 +121,7 @@ void BLAKE2B256_Update(BLAKE2B_CTX *b2b, const void *in_data, size_t len) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t *data = in_data;
|
||||
const uint8_t *data = reinterpret_cast<const uint8_t *>(in_data);
|
||||
size_t todo = sizeof(b2b->block) - b2b->block_used;
|
||||
if (todo > len) {
|
||||
todo = len;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2015, Google Inc.
|
||||
/* Copyright 2015 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
+28
-20
@@ -78,8 +78,9 @@ static const char hextable[] = "0123456789abcdef";
|
||||
|
||||
char *BN_bn2hex(const BIGNUM *bn) {
|
||||
int width = bn_minimal_width(bn);
|
||||
char *buf = OPENSSL_malloc(1 /* leading '-' */ + 1 /* zero is non-empty */ +
|
||||
width * BN_BYTES * 2 + 1 /* trailing NUL */);
|
||||
char *buf = reinterpret_cast<char *>(
|
||||
OPENSSL_malloc(1 /* leading '-' */ + 1 /* zero is non-empty */ +
|
||||
width * BN_BYTES * 2 + 1 /* trailing NUL */));
|
||||
if (buf == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -112,7 +113,7 @@ char *BN_bn2hex(const BIGNUM *bn) {
|
||||
|
||||
// decode_hex decodes |in_len| bytes of hex data from |in| and updates |bn|.
|
||||
static int decode_hex(BIGNUM *bn, const char *in, int in_len) {
|
||||
if (in_len > INT_MAX/4) {
|
||||
if (in_len > INT_MAX / 4) {
|
||||
OPENSSL_PUT_ERROR(BN, BN_R_BIGNUM_TOO_LONG);
|
||||
return 0;
|
||||
}
|
||||
@@ -163,8 +164,7 @@ static int decode_dec(BIGNUM *bn, const char *in, int in_len) {
|
||||
l *= 10;
|
||||
l += in[i] - '0';
|
||||
if (++j == BN_DEC_NUM) {
|
||||
if (!BN_mul_word(bn, BN_DEC_CONV) ||
|
||||
!BN_add_word(bn, l)) {
|
||||
if (!BN_mul_word(bn, BN_DEC_CONV) || !BN_add_word(bn, l)) {
|
||||
return 0;
|
||||
}
|
||||
l = 0;
|
||||
@@ -174,10 +174,11 @@ static int decode_dec(BIGNUM *bn, const char *in, int in_len) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef int (*decode_func) (BIGNUM *bn, const char *in, int in_len);
|
||||
typedef int (*char_test_func) (int c);
|
||||
typedef int (*decode_func)(BIGNUM *bn, const char *in, int in_len);
|
||||
typedef int (*char_test_func)(int c);
|
||||
|
||||
static int bn_x2bn(BIGNUM **outp, const char *in, decode_func decode, char_test_func want_char) {
|
||||
static int bn_x2bn(BIGNUM **outp, const char *in, decode_func decode,
|
||||
char_test_func want_char) {
|
||||
BIGNUM *ret = NULL;
|
||||
int neg = 0, i;
|
||||
int num;
|
||||
@@ -191,7 +192,8 @@ static int bn_x2bn(BIGNUM **outp, const char *in, decode_func decode, char_test_
|
||||
in++;
|
||||
}
|
||||
|
||||
for (i = 0; want_char((unsigned char)in[i]) && i + neg < INT_MAX; i++) {}
|
||||
for (i = 0; want_char((unsigned char)in[i]) && i + neg < INT_MAX; i++) {
|
||||
}
|
||||
|
||||
num = i + neg;
|
||||
if (outp == NULL) {
|
||||
@@ -238,7 +240,7 @@ char *BN_bn2dec(const BIGNUM *a) {
|
||||
// and fix at the end.
|
||||
BIGNUM *copy = NULL;
|
||||
CBB cbb;
|
||||
if (!CBB_init(&cbb, 16) ||
|
||||
if (!CBB_init(&cbb, 16) || //
|
||||
!CBB_add_u8(&cbb, 0 /* trailing NUL */)) {
|
||||
goto err;
|
||||
}
|
||||
@@ -270,7 +272,7 @@ char *BN_bn2dec(const BIGNUM *a) {
|
||||
}
|
||||
}
|
||||
|
||||
if (BN_is_negative(a) &&
|
||||
if (BN_is_negative(a) && //
|
||||
!CBB_add_u8(&cbb, '-')) {
|
||||
goto err;
|
||||
}
|
||||
@@ -282,7 +284,7 @@ char *BN_bn2dec(const BIGNUM *a) {
|
||||
}
|
||||
|
||||
// Reverse the buffer.
|
||||
for (size_t i = 0; i < len/2; i++) {
|
||||
for (size_t i = 0; i < len / 2; i++) {
|
||||
uint8_t tmp = data[i];
|
||||
data[i] = data[len - 1 - i];
|
||||
data[len - 1 - i] = tmp;
|
||||
@@ -308,7 +310,7 @@ int BN_asc2bn(BIGNUM **outp, const char *in) {
|
||||
}
|
||||
|
||||
if (in[0] == '0' && (in[1] == 'X' || in[1] == 'x')) {
|
||||
if (!BN_hex2bn(outp, in+2)) {
|
||||
if (!BN_hex2bn(outp, in + 2)) {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@@ -377,9 +379,7 @@ size_t BN_bn2mpi(const BIGNUM *in, uint8_t *out) {
|
||||
}
|
||||
|
||||
const size_t len = bytes + extend;
|
||||
if (len < bytes ||
|
||||
4 + len < len ||
|
||||
(len & 0xffffffff) != len) {
|
||||
if (len < bytes || 4 + len < len || (len & 0xffffffff) != len) {
|
||||
// If we cannot represent the number then we emit zero as the interface
|
||||
// doesn't allow an error to be signalled.
|
||||
if (out) {
|
||||
@@ -411,9 +411,9 @@ BIGNUM *BN_mpi2bn(const uint8_t *in, size_t len, BIGNUM *out) {
|
||||
OPENSSL_PUT_ERROR(BN, BN_R_BAD_ENCODING);
|
||||
return NULL;
|
||||
}
|
||||
const size_t in_len = ((size_t)in[0] << 24) |
|
||||
((size_t)in[1] << 16) |
|
||||
((size_t)in[2] << 8) |
|
||||
const size_t in_len = ((size_t)in[0] << 24) | //
|
||||
((size_t)in[1] << 16) | //
|
||||
((size_t)in[2] << 8) | //
|
||||
((size_t)in[3]);
|
||||
if (in_len != len - 4) {
|
||||
OPENSSL_PUT_ERROR(BN, BN_R_BAD_ENCODING);
|
||||
@@ -449,9 +449,17 @@ BIGNUM *BN_mpi2bn(const uint8_t *in, size_t len, BIGNUM *out) {
|
||||
}
|
||||
|
||||
int BN_bn2binpad(const BIGNUM *in, uint8_t *out, int len) {
|
||||
if (len < 0 ||
|
||||
if (len < 0 || //
|
||||
!BN_bn2bin_padded(out, (size_t)len, in)) {
|
||||
return -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
int BN_bn2lebinpad(const BIGNUM *in, uint8_t *out, int len) {
|
||||
if (len < 0 || //
|
||||
!BN_bn2le_padded(out, (size_t)len, in)) {
|
||||
return -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
+4
-11
@@ -58,22 +58,14 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
|
||||
#include "../internal.h"
|
||||
|
||||
|
||||
BUF_MEM *BUF_MEM_new(void) {
|
||||
BUF_MEM *ret;
|
||||
|
||||
ret = OPENSSL_malloc(sizeof(BUF_MEM));
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OPENSSL_memset(ret, 0, sizeof(BUF_MEM));
|
||||
return ret;
|
||||
return reinterpret_cast<BUF_MEM *>(OPENSSL_zalloc(sizeof(BUF_MEM)));
|
||||
}
|
||||
|
||||
void BUF_MEM_free(BUF_MEM *buf) {
|
||||
@@ -102,7 +94,8 @@ int BUF_MEM_reserve(BUF_MEM *buf, size_t cap) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *new_buf = OPENSSL_realloc(buf->data, alloc_size);
|
||||
char *new_buf =
|
||||
reinterpret_cast<char *>(OPENSSL_realloc(buf->data, alloc_size));
|
||||
if (new_buf == NULL) {
|
||||
return 0;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2016, Google Inc.
|
||||
/* Copyright 2016 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
+8
-9
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2014, Google Inc.
|
||||
/* Copyright 2014 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -18,13 +18,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "../internal.h"
|
||||
|
||||
|
||||
// kMaxDepth is a just a sanity limit. The code should be such that the length
|
||||
// of the input being processes always decreases. None the less, a very large
|
||||
// input could otherwise cause the stack to overflow.
|
||||
static const uint32_t kMaxDepth = 2048;
|
||||
// kMaxDepth limits the recursion depth to avoid overflowing the stack.
|
||||
static const uint32_t kMaxDepth = 128;
|
||||
|
||||
// is_string_type returns one if |tag| is a string type and zero otherwise. It
|
||||
// ignores the constructed bit.
|
||||
@@ -56,13 +53,11 @@ static int is_string_type(CBS_ASN1_TAG tag) {
|
||||
// found. The value of |orig_in| is not changed. It returns one on success (i.e.
|
||||
// |*ber_found| was set) and zero on error.
|
||||
static int cbs_find_ber(const CBS *orig_in, int *ber_found, uint32_t depth) {
|
||||
CBS in;
|
||||
|
||||
if (depth > kMaxDepth) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
CBS_init(&in, CBS_data(orig_in), CBS_len(orig_in));
|
||||
CBS in = *orig_in;
|
||||
*ber_found = 0;
|
||||
|
||||
while (CBS_len(&in) > 0) {
|
||||
@@ -87,6 +82,10 @@ static int cbs_find_ber(const CBS *orig_in, int *ber_found, uint32_t depth) {
|
||||
!cbs_find_ber(&contents, ber_found, depth + 1)) {
|
||||
return 0;
|
||||
}
|
||||
if (*ber_found) {
|
||||
// We already found BER. No need to continue parsing.
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+74
-60
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2014, Google Inc.
|
||||
/* Copyright 2014 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -18,15 +18,13 @@
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
|
||||
#include "../internal.h"
|
||||
|
||||
|
||||
void CBB_zero(CBB *cbb) {
|
||||
OPENSSL_memset(cbb, 0, sizeof(CBB));
|
||||
}
|
||||
void CBB_zero(CBB *cbb) { OPENSSL_memset(cbb, 0, sizeof(CBB)); }
|
||||
|
||||
static void cbb_init(CBB *cbb, uint8_t *buf, size_t cap, int can_resize) {
|
||||
cbb->is_child = 0;
|
||||
@@ -41,7 +39,7 @@ static void cbb_init(CBB *cbb, uint8_t *buf, size_t cap, int can_resize) {
|
||||
int CBB_init(CBB *cbb, size_t initial_capacity) {
|
||||
CBB_zero(cbb);
|
||||
|
||||
uint8_t *buf = OPENSSL_malloc(initial_capacity);
|
||||
uint8_t *buf = reinterpret_cast<uint8_t *>(OPENSSL_malloc(initial_capacity));
|
||||
if (initial_capacity > 0 && buf == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -92,7 +90,8 @@ static int cbb_buffer_reserve(struct cbb_buffer_st *base, uint8_t **out,
|
||||
if (newcap < base->cap || newcap < newlen) {
|
||||
newcap = newlen;
|
||||
}
|
||||
uint8_t *newbuf = OPENSSL_realloc(base->buf, newcap);
|
||||
uint8_t *newbuf =
|
||||
reinterpret_cast<uint8_t *>(OPENSSL_realloc(base->buf, newcap));
|
||||
if (newbuf == NULL) {
|
||||
goto err;
|
||||
}
|
||||
@@ -155,6 +154,29 @@ static struct cbb_buffer_st *cbb_get_base(CBB *cbb) {
|
||||
return &cbb->u.base;
|
||||
}
|
||||
|
||||
static void cbb_on_error(CBB *cbb) {
|
||||
// Due to C's lack of destructors and |CBB|'s auto-flushing API, a failing
|
||||
// |CBB|-taking function may leave a dangling pointer to a child |CBB|. As a
|
||||
// result, the convention is callers may not write to |CBB|s that have failed.
|
||||
// But, as a safety measure, we lock the |CBB| into an error state. Once the
|
||||
// error bit is set, |cbb->child| will not be read.
|
||||
//
|
||||
// TODO(davidben): This still isn't quite ideal. A |CBB| function *outside*
|
||||
// this file may originate an error while the |CBB| points to a local child.
|
||||
// In that case we don't set the error bit and are reliant on the error
|
||||
// convention. Perhaps we allow |CBB_cleanup| on child |CBB|s and make every
|
||||
// child's |CBB_cleanup| set the error bit if unflushed. That will be
|
||||
// convenient for C++ callers, but very tedious for C callers. So C callers
|
||||
// perhaps should get a |CBB_on_error| function that can be, less tediously,
|
||||
// stuck in a |goto err| block.
|
||||
cbb_get_base(cbb)->error = 1;
|
||||
|
||||
// Clearing the pointer is not strictly necessary, but GCC's dangling pointer
|
||||
// warning does not know |cbb->child| will not be read once |error| is set
|
||||
// above.
|
||||
cbb->child = NULL;
|
||||
}
|
||||
|
||||
// CBB_flush recurses and then writes out any pending length prefix. The
|
||||
// current length of the underlying base is taken to be the length of the
|
||||
// length-prefixed data.
|
||||
@@ -177,13 +199,13 @@ int CBB_flush(CBB *cbb) {
|
||||
assert(child->base == base);
|
||||
size_t child_start = child->offset + child->pending_len_len;
|
||||
|
||||
if (!CBB_flush(cbb->child) ||
|
||||
child_start < child->offset ||
|
||||
size_t len;
|
||||
if (!CBB_flush(cbb->child) || child_start < child->offset ||
|
||||
base->len < child_start) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
size_t len = base->len - child_start;
|
||||
len = base->len - child_start;
|
||||
|
||||
if (child->pending_is_asn1) {
|
||||
// For ASN.1 we assume that we'll only need a single byte for the length.
|
||||
@@ -192,7 +214,7 @@ int CBB_flush(CBB *cbb) {
|
||||
uint8_t len_len;
|
||||
uint8_t initial_length_byte;
|
||||
|
||||
assert (child->pending_len_len == 1);
|
||||
assert(child->pending_len_len == 1);
|
||||
|
||||
if (len > 0xfffffffe) {
|
||||
OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW);
|
||||
@@ -244,7 +266,7 @@ int CBB_flush(CBB *cbb) {
|
||||
return 1;
|
||||
|
||||
err:
|
||||
base->error = 1;
|
||||
cbb_on_error(cbb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -380,8 +402,7 @@ int CBB_add_zeros(CBB *cbb, size_t len) {
|
||||
}
|
||||
|
||||
int CBB_add_space(CBB *cbb, uint8_t **out_data, size_t len) {
|
||||
if (!CBB_flush(cbb) ||
|
||||
!cbb_buffer_add(cbb_get_base(cbb), out_data, len)) {
|
||||
if (!CBB_flush(cbb) || !cbb_buffer_add(cbb_get_base(cbb), out_data, len)) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -398,9 +419,7 @@ int CBB_reserve(CBB *cbb, uint8_t **out_data, size_t len) {
|
||||
int CBB_did_write(CBB *cbb, size_t len) {
|
||||
struct cbb_buffer_st *base = cbb_get_base(cbb);
|
||||
size_t newlen = base->len + len;
|
||||
if (cbb->child != NULL ||
|
||||
newlen < base->len ||
|
||||
newlen > base->cap) {
|
||||
if (cbb->child != NULL || newlen < base->len || newlen > base->cap) {
|
||||
return 0;
|
||||
}
|
||||
base->len = newlen;
|
||||
@@ -420,40 +439,30 @@ static int cbb_add_u(CBB *cbb, uint64_t v, size_t len_len) {
|
||||
|
||||
// |v| must fit in |len_len| bytes.
|
||||
if (v != 0) {
|
||||
cbb_get_base(cbb)->error = 1;
|
||||
cbb_on_error(cbb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CBB_add_u8(CBB *cbb, uint8_t value) {
|
||||
return cbb_add_u(cbb, value, 1);
|
||||
}
|
||||
int CBB_add_u8(CBB *cbb, uint8_t value) { return cbb_add_u(cbb, value, 1); }
|
||||
|
||||
int CBB_add_u16(CBB *cbb, uint16_t value) {
|
||||
return cbb_add_u(cbb, value, 2);
|
||||
}
|
||||
int CBB_add_u16(CBB *cbb, uint16_t value) { return cbb_add_u(cbb, value, 2); }
|
||||
|
||||
int CBB_add_u16le(CBB *cbb, uint16_t value) {
|
||||
return CBB_add_u16(cbb, CRYPTO_bswap2(value));
|
||||
}
|
||||
|
||||
int CBB_add_u24(CBB *cbb, uint32_t value) {
|
||||
return cbb_add_u(cbb, value, 3);
|
||||
}
|
||||
int CBB_add_u24(CBB *cbb, uint32_t value) { return cbb_add_u(cbb, value, 3); }
|
||||
|
||||
int CBB_add_u32(CBB *cbb, uint32_t value) {
|
||||
return cbb_add_u(cbb, value, 4);
|
||||
}
|
||||
int CBB_add_u32(CBB *cbb, uint32_t value) { return cbb_add_u(cbb, value, 4); }
|
||||
|
||||
int CBB_add_u32le(CBB *cbb, uint32_t value) {
|
||||
return CBB_add_u32(cbb, CRYPTO_bswap4(value));
|
||||
}
|
||||
|
||||
int CBB_add_u64(CBB *cbb, uint64_t value) {
|
||||
return cbb_add_u(cbb, value, 8);
|
||||
}
|
||||
int CBB_add_u64(CBB *cbb, uint64_t value) { return cbb_add_u(cbb, value, 8); }
|
||||
|
||||
int CBB_add_u64le(CBB *cbb, uint64_t value) {
|
||||
return CBB_add_u64(cbb, CRYPTO_bswap8(value));
|
||||
@@ -478,13 +487,13 @@ int CBB_add_asn1_uint64(CBB *cbb, uint64_t value) {
|
||||
|
||||
int CBB_add_asn1_uint64_with_tag(CBB *cbb, uint64_t value, CBS_ASN1_TAG tag) {
|
||||
CBB child;
|
||||
int started = 0;
|
||||
if (!CBB_add_asn1(cbb, &child, tag)) {
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
int started = 0;
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
uint8_t byte = (value >> 8*(7-i)) & 0xff;
|
||||
uint8_t byte = (value >> 8 * (7 - i)) & 0xff;
|
||||
if (!started) {
|
||||
if (byte == 0) {
|
||||
// Don't encode leading zeros.
|
||||
@@ -493,21 +502,25 @@ int CBB_add_asn1_uint64_with_tag(CBB *cbb, uint64_t value, CBS_ASN1_TAG tag) {
|
||||
// If the high bit is set, add a padding byte to make it
|
||||
// unsigned.
|
||||
if ((byte & 0x80) && !CBB_add_u8(&child, 0)) {
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
started = 1;
|
||||
}
|
||||
if (!CBB_add_u8(&child, byte)) {
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
// 0 is encoded as a single 0, not the empty string.
|
||||
if (!started && !CBB_add_u8(&child, 0)) {
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
return CBB_flush(cbb);
|
||||
|
||||
err:
|
||||
cbb_on_error(cbb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CBB_add_asn1_int64(CBB *cbb, int64_t value) {
|
||||
@@ -529,21 +542,25 @@ int CBB_add_asn1_int64_with_tag(CBB *cbb, int64_t value, CBS_ASN1_TAG tag) {
|
||||
|
||||
CBB child;
|
||||
if (!CBB_add_asn1(cbb, &child, tag)) {
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
for (int i = start; i >= 0; i--) {
|
||||
if (!CBB_add_u8(&child, bytes[i])) {
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
return CBB_flush(cbb);
|
||||
|
||||
err:
|
||||
cbb_on_error(cbb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CBB_add_asn1_octet_string(CBB *cbb, const uint8_t *data, size_t data_len) {
|
||||
CBB child;
|
||||
if (!CBB_add_asn1(cbb, &child, CBS_ASN1_OCTETSTRING) ||
|
||||
!CBB_add_bytes(&child, data, data_len) ||
|
||||
!CBB_flush(cbb)) {
|
||||
!CBB_add_bytes(&child, data, data_len) || !CBB_flush(cbb)) {
|
||||
cbb_on_error(cbb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -553,8 +570,8 @@ int CBB_add_asn1_octet_string(CBB *cbb, const uint8_t *data, size_t data_len) {
|
||||
int CBB_add_asn1_bool(CBB *cbb, int value) {
|
||||
CBB child;
|
||||
if (!CBB_add_asn1(cbb, &child, CBS_ASN1_BOOLEAN) ||
|
||||
!CBB_add_u8(&child, value != 0 ? 0xff : 0) ||
|
||||
!CBB_flush(cbb)) {
|
||||
!CBB_add_u8(&child, value != 0 ? 0xff : 0) || !CBB_flush(cbb)) {
|
||||
cbb_on_error(cbb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -587,24 +604,20 @@ int CBB_add_asn1_oid_from_text(CBB *cbb, const char *text, size_t len) {
|
||||
|
||||
// OIDs must have at least two components.
|
||||
uint64_t a, b;
|
||||
if (!parse_dotted_decimal(&cbs, &a) ||
|
||||
!parse_dotted_decimal(&cbs, &b)) {
|
||||
if (!parse_dotted_decimal(&cbs, &a) || !parse_dotted_decimal(&cbs, &b)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The first component is encoded as 40 * |a| + |b|. This assumes that |a| is
|
||||
// 0, 1, or 2 and that, when it is 0 or 1, |b| is at most 39.
|
||||
if (a > 2 ||
|
||||
(a < 2 && b > 39) ||
|
||||
b > UINT64_MAX - 80 ||
|
||||
if (a > 2 || (a < 2 && b > 39) || b > UINT64_MAX - 80 ||
|
||||
!add_base128_integer(cbb, 40u * a + b)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The remaining components are encoded unmodified.
|
||||
while (CBS_len(&cbs) > 0) {
|
||||
if (!parse_dotted_decimal(&cbs, &a) ||
|
||||
!add_base128_integer(cbb, a)) {
|
||||
if (!parse_dotted_decimal(&cbs, &a) || !add_base128_integer(cbb, a)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -615,7 +628,8 @@ int CBB_add_asn1_oid_from_text(CBB *cbb, const char *text, size_t len) {
|
||||
static int compare_set_of_element(const void *a_ptr, const void *b_ptr) {
|
||||
// See X.690, section 11.6 for the ordering. They are sorted in ascending
|
||||
// order by their DER encoding.
|
||||
const CBS *a = a_ptr, *b = b_ptr;
|
||||
const CBS *a = reinterpret_cast<const CBS *>(a_ptr),
|
||||
*b = reinterpret_cast<const CBS *>(b_ptr);
|
||||
size_t a_len = CBS_len(a), b_len = CBS_len(b);
|
||||
size_t min_len = a_len < b_len ? a_len : b_len;
|
||||
int ret = OPENSSL_memcmp(CBS_data(a), CBS_data(b), min_len);
|
||||
@@ -649,16 +663,17 @@ int CBB_flush_asn1_set_of(CBB *cbb) {
|
||||
if (num_children < 2) {
|
||||
return 1; // Nothing to do. This is the common case for X.509.
|
||||
}
|
||||
if (num_children > ((size_t)-1) / sizeof(CBS)) {
|
||||
return 0; // Overflow.
|
||||
}
|
||||
|
||||
// Parse out the children and sort. We alias them into a copy of so they
|
||||
// remain valid as we rewrite |cbb|.
|
||||
int ret = 0;
|
||||
size_t buf_len = CBB_len(cbb);
|
||||
uint8_t *buf = OPENSSL_memdup(CBB_data(cbb), buf_len);
|
||||
CBS *children = OPENSSL_malloc(num_children * sizeof(CBS));
|
||||
uint8_t *buf =
|
||||
reinterpret_cast<uint8_t *>(OPENSSL_memdup(CBB_data(cbb), buf_len));
|
||||
CBS *children =
|
||||
reinterpret_cast<CBS *>(OPENSSL_calloc(num_children, sizeof(CBS)));
|
||||
uint8_t *out;
|
||||
size_t offset = 0;
|
||||
if (buf == NULL || children == NULL) {
|
||||
goto err;
|
||||
}
|
||||
@@ -671,8 +686,7 @@ int CBB_flush_asn1_set_of(CBB *cbb) {
|
||||
qsort(children, num_children, sizeof(CBS), compare_set_of_element);
|
||||
|
||||
// Write the contents back in the new order.
|
||||
uint8_t *out = (uint8_t *)CBB_data(cbb);
|
||||
size_t offset = 0;
|
||||
out = (uint8_t *)CBB_data(cbb);
|
||||
for (size_t i = 0; i < num_children; i++) {
|
||||
OPENSSL_memcpy(out + offset, CBS_data(&children[i]), CBS_len(&children[i]));
|
||||
offset += CBS_len(&children[i]);
|
||||
+23
-45
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2014, Google Inc.
|
||||
/* Copyright 2014 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -26,11 +26,6 @@
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
void CBS_init(CBS *cbs, const uint8_t *data, size_t len) {
|
||||
cbs->data = data;
|
||||
cbs->len = len;
|
||||
}
|
||||
|
||||
static int cbs_get(CBS *cbs, const uint8_t **p, size_t n) {
|
||||
if (cbs->len < n) {
|
||||
return 0;
|
||||
@@ -47,14 +42,6 @@ int CBS_skip(CBS *cbs, size_t len) {
|
||||
return cbs_get(cbs, &dummy, len);
|
||||
}
|
||||
|
||||
const uint8_t *CBS_data(const CBS *cbs) {
|
||||
return cbs->data;
|
||||
}
|
||||
|
||||
size_t CBS_len(const CBS *cbs) {
|
||||
return cbs->len;
|
||||
}
|
||||
|
||||
int CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len) {
|
||||
OPENSSL_free(*out_ptr);
|
||||
*out_ptr = NULL;
|
||||
@@ -63,7 +50,7 @@ int CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len) {
|
||||
if (cbs->len == 0) {
|
||||
return 1;
|
||||
}
|
||||
*out_ptr = OPENSSL_memdup(cbs->data, cbs->len);
|
||||
*out_ptr = reinterpret_cast<uint8_t *>(OPENSSL_memdup(cbs->data, cbs->len));
|
||||
if (*out_ptr == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -75,7 +62,7 @@ int CBS_strdup(const CBS *cbs, char **out_ptr) {
|
||||
if (*out_ptr != NULL) {
|
||||
OPENSSL_free(*out_ptr);
|
||||
}
|
||||
*out_ptr = OPENSSL_strndup((const char*)cbs->data, cbs->len);
|
||||
*out_ptr = OPENSSL_strndup((const char *)cbs->data, cbs->len);
|
||||
return (*out_ptr != NULL);
|
||||
}
|
||||
|
||||
@@ -157,9 +144,7 @@ int CBS_get_u32le(CBS *cbs, uint32_t *out) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CBS_get_u64(CBS *cbs, uint64_t *out) {
|
||||
return cbs_get_u(cbs, out, 8);
|
||||
}
|
||||
int CBS_get_u64(CBS *cbs, uint64_t *out) { return cbs_get_u(cbs, out, 8); }
|
||||
|
||||
int CBS_get_u64le(CBS *cbs, uint64_t *out) {
|
||||
if (!cbs_get_u(cbs, out, 8)) {
|
||||
@@ -220,7 +205,8 @@ int CBS_get_u24_length_prefixed(CBS *cbs, CBS *out) {
|
||||
}
|
||||
|
||||
int CBS_get_until_first(CBS *cbs, CBS *out, uint8_t c) {
|
||||
const uint8_t *split = OPENSSL_memchr(CBS_data(cbs), c, CBS_len(cbs));
|
||||
const uint8_t *split = reinterpret_cast<const uint8_t *>(
|
||||
OPENSSL_memchr(CBS_data(cbs), c, CBS_len(cbs)));
|
||||
if (split == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -236,7 +222,7 @@ int CBS_get_u64_decimal(CBS *cbs, uint64_t *out) {
|
||||
break;
|
||||
}
|
||||
CBS_skip(cbs, 1);
|
||||
if (// Forbid stray leading zeros.
|
||||
if (/* Forbid stray leading zeros */
|
||||
(v == 0 && seen_digit) ||
|
||||
// Check for overflow.
|
||||
v > UINT64_MAX / 10 || //
|
||||
@@ -354,7 +340,7 @@ static int cbs_get_any_asn1_element(CBS *cbs, CBS *out, CBS_ASN1_TAG *out_tag,
|
||||
// 8.1.3.
|
||||
if ((length_byte & 0x80) == 0) {
|
||||
// Short form length.
|
||||
len = ((size_t) length_byte) + header_len;
|
||||
len = ((size_t)length_byte) + header_len;
|
||||
if (out_header_len != NULL) {
|
||||
*out_header_len = header_len;
|
||||
}
|
||||
@@ -433,7 +419,7 @@ int CBS_get_any_asn1(CBS *cbs, CBS *out, CBS_ASN1_TAG *out_tag) {
|
||||
}
|
||||
|
||||
int CBS_get_any_asn1_element(CBS *cbs, CBS *out, CBS_ASN1_TAG *out_tag,
|
||||
size_t *out_header_len) {
|
||||
size_t *out_header_len) {
|
||||
return cbs_get_any_asn1_element(cbs, out, out_tag, out_header_len, NULL, NULL,
|
||||
/*ber_ok=*/0);
|
||||
}
|
||||
@@ -520,18 +506,15 @@ int CBS_get_asn1_int64(CBS *cbs, int64_t *out) {
|
||||
return 0;
|
||||
}
|
||||
uint8_t sign_extend[sizeof(int64_t)];
|
||||
memset(sign_extend, is_negative ? 0xff : 0, sizeof(sign_extend));
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
sign_extend[i] = data[len - i - 1];
|
||||
}
|
||||
memcpy(out, sign_extend, sizeof(sign_extend));
|
||||
OPENSSL_memset(sign_extend, is_negative ? 0xff : 0, sizeof(sign_extend));
|
||||
OPENSSL_memcpy(sign_extend + sizeof(int64_t) - len, data, len);
|
||||
*out = CRYPTO_load_u64_be(sign_extend);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CBS_get_asn1_bool(CBS *cbs, int *out) {
|
||||
CBS bytes;
|
||||
if (!CBS_get_asn1(cbs, &bytes, CBS_ASN1_BOOLEAN) ||
|
||||
CBS_len(&bytes) != 1) {
|
||||
if (!CBS_get_asn1(cbs, &bytes, CBS_ASN1_BOOLEAN) || CBS_len(&bytes) != 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -544,7 +527,8 @@ int CBS_get_asn1_bool(CBS *cbs, int *out) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CBS_get_optional_asn1(CBS *cbs, CBS *out, int *out_present, CBS_ASN1_TAG tag) {
|
||||
int CBS_get_optional_asn1(CBS *cbs, CBS *out, int *out_present,
|
||||
CBS_ASN1_TAG tag) {
|
||||
int present = 0;
|
||||
|
||||
if (CBS_peek_asn1_tag(cbs, tag)) {
|
||||
@@ -591,8 +575,7 @@ int CBS_get_optional_asn1_uint64(CBS *cbs, uint64_t *out, CBS_ASN1_TAG tag,
|
||||
return 0;
|
||||
}
|
||||
if (present) {
|
||||
if (!CBS_get_asn1_uint64(&child, out) ||
|
||||
CBS_len(&child) != 0) {
|
||||
if (!CBS_get_asn1_uint64(&child, out) || CBS_len(&child) != 0) {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@@ -612,8 +595,7 @@ int CBS_get_optional_asn1_bool(CBS *cbs, int *out, CBS_ASN1_TAG tag,
|
||||
uint8_t boolean;
|
||||
|
||||
if (!CBS_get_asn1(&child, &child2, CBS_ASN1_BOOLEAN) ||
|
||||
CBS_len(&child2) != 1 ||
|
||||
CBS_len(&child) != 0) {
|
||||
CBS_len(&child2) != 1 || CBS_len(&child) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -634,8 +616,7 @@ int CBS_get_optional_asn1_bool(CBS *cbs, int *out, CBS_ASN1_TAG tag,
|
||||
int CBS_is_valid_asn1_bitstring(const CBS *cbs) {
|
||||
CBS in = *cbs;
|
||||
uint8_t num_unused_bits;
|
||||
if (!CBS_get_u8(&in, &num_unused_bits) ||
|
||||
num_unused_bits > 7) {
|
||||
if (!CBS_get_u8(&in, &num_unused_bits) || num_unused_bits > 7) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -722,12 +703,12 @@ int CBS_is_valid_asn1_oid(const CBS *cbs) {
|
||||
}
|
||||
|
||||
char *CBS_asn1_oid_to_text(const CBS *cbs) {
|
||||
CBS copy = *cbs;
|
||||
CBB cbb;
|
||||
if (!CBB_init(&cbb, 32)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
CBS copy = *cbs;
|
||||
// The first component is 40 * value1 + value2, where value1 is 0, 1, or 2.
|
||||
uint64_t v;
|
||||
if (!parse_base128_integer(©, &v)) {
|
||||
@@ -739,15 +720,13 @@ char *CBS_asn1_oid_to_text(const CBS *cbs) {
|
||||
!add_decimal(&cbb, v - 80)) {
|
||||
goto err;
|
||||
}
|
||||
} else if (!add_decimal(&cbb, v / 40) ||
|
||||
!CBB_add_u8(&cbb, '.') ||
|
||||
} else if (!add_decimal(&cbb, v / 40) || !CBB_add_u8(&cbb, '.') ||
|
||||
!add_decimal(&cbb, v % 40)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
while (CBS_len(©) != 0) {
|
||||
if (!parse_base128_integer(©, &v) ||
|
||||
!CBB_add_u8(&cbb, '.') ||
|
||||
if (!parse_base128_integer(©, &v) || !CBB_add_u8(&cbb, '.') ||
|
||||
!add_decimal(&cbb, v)) {
|
||||
goto err;
|
||||
}
|
||||
@@ -755,8 +734,7 @@ char *CBS_asn1_oid_to_text(const CBS *cbs) {
|
||||
|
||||
uint8_t *txt;
|
||||
size_t txt_len;
|
||||
if (!CBB_add_u8(&cbb, '\0') ||
|
||||
!CBB_finish(&cbb, &txt, &txt_len)) {
|
||||
if (!CBB_add_u8(&cbb, '\0') || !CBB_finish(&cbb, &txt, &txt_len)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -829,7 +807,7 @@ static int CBS_parse_rfc5280_time_internal(const CBS *cbs, int is_gentime,
|
||||
if (!cbs_get_two_digits(©, &tmp)) {
|
||||
return 0;
|
||||
}
|
||||
year += tmp;
|
||||
year += tmp;
|
||||
} else {
|
||||
year = 1900;
|
||||
if (!cbs_get_two_digits(©, &tmp)) {
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2014, Google Inc.
|
||||
/* Copyright 2014 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -67,28 +67,6 @@ OPENSSL_EXPORT int CBS_get_asn1_implicit_string(CBS *in, CBS *out,
|
||||
int CBB_finish_i2d(CBB *cbb, uint8_t **outp);
|
||||
|
||||
|
||||
// Unicode utilities.
|
||||
|
||||
// The following functions read one Unicode code point from |cbs| with the
|
||||
// corresponding encoding and store it in |*out|. They return one on success and
|
||||
// zero on error.
|
||||
OPENSSL_EXPORT int cbs_get_utf8(CBS *cbs, uint32_t *out);
|
||||
OPENSSL_EXPORT int cbs_get_latin1(CBS *cbs, uint32_t *out);
|
||||
OPENSSL_EXPORT int cbs_get_ucs2_be(CBS *cbs, uint32_t *out);
|
||||
OPENSSL_EXPORT int cbs_get_utf32_be(CBS *cbs, uint32_t *out);
|
||||
|
||||
// cbb_get_utf8_len returns the number of bytes needed to represent |u| in
|
||||
// UTF-8.
|
||||
OPENSSL_EXPORT size_t cbb_get_utf8_len(uint32_t u);
|
||||
|
||||
// The following functions encode |u| to |cbb| with the corresponding
|
||||
// encoding. They return one on success and zero on error.
|
||||
OPENSSL_EXPORT int cbb_add_utf8(CBB *cbb, uint32_t u);
|
||||
OPENSSL_EXPORT int cbb_add_latin1(CBB *cbb, uint32_t u);
|
||||
OPENSSL_EXPORT int cbb_add_ucs2_be(CBB *cbb, uint32_t u);
|
||||
OPENSSL_EXPORT int cbb_add_utf32_be(CBB *cbb, uint32_t u);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern C
|
||||
#endif
|
||||
|
||||
+13
-12
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2018, Google Inc.
|
||||
/* Copyright 2018 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -18,11 +18,12 @@
|
||||
|
||||
|
||||
static int is_valid_code_point(uint32_t v) {
|
||||
// References in the following are to Unicode 9.0.0.
|
||||
// References in the following are to Unicode 15.0.0.
|
||||
if (// The Unicode space runs from zero to 0x10ffff (3.4 D9).
|
||||
v > 0x10ffff ||
|
||||
// Values 0x...fffe, 0x...ffff, and 0xfdd0-0xfdef are permanently reserved
|
||||
// (3.4 D14)
|
||||
// as noncharacters (3.4 D14). See also 23.7. As our APIs are intended for
|
||||
// "open interchange", such as ASN.1, we reject them.
|
||||
(v & 0xfffe) == 0xfffe ||
|
||||
(v >= 0xfdd0 && v <= 0xfdef) ||
|
||||
// Surrogate code points are invalid (3.2 C1).
|
||||
@@ -38,7 +39,7 @@ static int is_valid_code_point(uint32_t v) {
|
||||
// TOP_BITS returns a byte with the top |n| bits set.
|
||||
#define TOP_BITS(n) ((uint8_t)~BOTTOM_BITS(8 - (n)))
|
||||
|
||||
int cbs_get_utf8(CBS *cbs, uint32_t *out) {
|
||||
int CBS_get_utf8(CBS *cbs, uint32_t *out) {
|
||||
uint8_t c;
|
||||
if (!CBS_get_u8(cbs, &c)) {
|
||||
return 0;
|
||||
@@ -80,7 +81,7 @@ int cbs_get_utf8(CBS *cbs, uint32_t *out) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cbs_get_latin1(CBS *cbs, uint32_t *out) {
|
||||
int CBS_get_latin1(CBS *cbs, uint32_t *out) {
|
||||
uint8_t c;
|
||||
if (!CBS_get_u8(cbs, &c)) {
|
||||
return 0;
|
||||
@@ -89,7 +90,7 @@ int cbs_get_latin1(CBS *cbs, uint32_t *out) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cbs_get_ucs2_be(CBS *cbs, uint32_t *out) {
|
||||
int CBS_get_ucs2_be(CBS *cbs, uint32_t *out) {
|
||||
// Note UCS-2 (used by BMPString) does not support surrogates.
|
||||
uint16_t c;
|
||||
if (!CBS_get_u16(cbs, &c) ||
|
||||
@@ -100,11 +101,11 @@ int cbs_get_ucs2_be(CBS *cbs, uint32_t *out) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cbs_get_utf32_be(CBS *cbs, uint32_t *out) {
|
||||
int CBS_get_utf32_be(CBS *cbs, uint32_t *out) {
|
||||
return CBS_get_u32(cbs, out) && is_valid_code_point(*out);
|
||||
}
|
||||
|
||||
size_t cbb_get_utf8_len(uint32_t u) {
|
||||
size_t CBB_get_utf8_len(uint32_t u) {
|
||||
if (u <= 0x7f) {
|
||||
return 1;
|
||||
}
|
||||
@@ -117,7 +118,7 @@ size_t cbb_get_utf8_len(uint32_t u) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
int cbb_add_utf8(CBB *cbb, uint32_t u) {
|
||||
int CBB_add_utf8(CBB *cbb, uint32_t u) {
|
||||
if (!is_valid_code_point(u)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -142,14 +143,14 @@ int cbb_add_utf8(CBB *cbb, uint32_t u) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cbb_add_latin1(CBB *cbb, uint32_t u) {
|
||||
int CBB_add_latin1(CBB *cbb, uint32_t u) {
|
||||
return u <= 0xff && CBB_add_u8(cbb, (uint8_t)u);
|
||||
}
|
||||
|
||||
int cbb_add_ucs2_be(CBB *cbb, uint32_t u) {
|
||||
int CBB_add_ucs2_be(CBB *cbb, uint32_t u) {
|
||||
return u <= 0xffff && is_valid_code_point(u) && CBB_add_u16(cbb, (uint16_t)u);
|
||||
}
|
||||
|
||||
int cbb_add_utf32_be(CBB *cbb, uint32_t u) {
|
||||
int CBB_add_utf32_be(CBB *cbb, uint32_t u) {
|
||||
return is_valid_code_point(u) && CBB_add_u32(cbb, u);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,987 +0,0 @@
|
||||
#define BORINGSSL_PREFIX CCryptoBoringSSL
|
||||
#if defined(__i386__) && defined(_WIN32)
|
||||
; This file is generated from a similarly-named Perl script in the BoringSSL
|
||||
; source tree. Do not edit by hand.
|
||||
|
||||
%ifdef BORINGSSL_PREFIX
|
||||
%include "boringssl_prefix_symbols_nasm.inc"
|
||||
%endif
|
||||
%ifidn __OUTPUT_FORMAT__, win32
|
||||
%ifidn __OUTPUT_FORMAT__,obj
|
||||
section code use32 class=code align=64
|
||||
%elifidn __OUTPUT_FORMAT__,win32
|
||||
$@feat.00 equ 1
|
||||
section .text code align=64
|
||||
%else
|
||||
section .text code
|
||||
%endif
|
||||
global _ChaCha20_ctr32
|
||||
align 16
|
||||
_ChaCha20_ctr32:
|
||||
L$_ChaCha20_ctr32_begin:
|
||||
push ebp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
xor eax,eax
|
||||
cmp eax,DWORD [28+esp]
|
||||
je NEAR L$000no_data
|
||||
call L$pic_point
|
||||
L$pic_point:
|
||||
pop eax
|
||||
lea ebp,[_OPENSSL_ia32cap_P]
|
||||
test DWORD [ebp],16777216
|
||||
jz NEAR L$001x86
|
||||
test DWORD [4+ebp],512
|
||||
jz NEAR L$001x86
|
||||
jmp NEAR L$ssse3_shortcut
|
||||
L$001x86:
|
||||
mov esi,DWORD [32+esp]
|
||||
mov edi,DWORD [36+esp]
|
||||
sub esp,132
|
||||
mov eax,DWORD [esi]
|
||||
mov ebx,DWORD [4+esi]
|
||||
mov ecx,DWORD [8+esi]
|
||||
mov edx,DWORD [12+esi]
|
||||
mov DWORD [80+esp],eax
|
||||
mov DWORD [84+esp],ebx
|
||||
mov DWORD [88+esp],ecx
|
||||
mov DWORD [92+esp],edx
|
||||
mov eax,DWORD [16+esi]
|
||||
mov ebx,DWORD [20+esi]
|
||||
mov ecx,DWORD [24+esi]
|
||||
mov edx,DWORD [28+esi]
|
||||
mov DWORD [96+esp],eax
|
||||
mov DWORD [100+esp],ebx
|
||||
mov DWORD [104+esp],ecx
|
||||
mov DWORD [108+esp],edx
|
||||
mov eax,DWORD [edi]
|
||||
mov ebx,DWORD [4+edi]
|
||||
mov ecx,DWORD [8+edi]
|
||||
mov edx,DWORD [12+edi]
|
||||
sub eax,1
|
||||
mov DWORD [112+esp],eax
|
||||
mov DWORD [116+esp],ebx
|
||||
mov DWORD [120+esp],ecx
|
||||
mov DWORD [124+esp],edx
|
||||
jmp NEAR L$002entry
|
||||
align 16
|
||||
L$003outer_loop:
|
||||
mov DWORD [156+esp],ebx
|
||||
mov DWORD [152+esp],eax
|
||||
mov DWORD [160+esp],ecx
|
||||
L$002entry:
|
||||
mov eax,1634760805
|
||||
mov DWORD [4+esp],857760878
|
||||
mov DWORD [8+esp],2036477234
|
||||
mov DWORD [12+esp],1797285236
|
||||
mov ebx,DWORD [84+esp]
|
||||
mov ebp,DWORD [88+esp]
|
||||
mov ecx,DWORD [104+esp]
|
||||
mov esi,DWORD [108+esp]
|
||||
mov edx,DWORD [116+esp]
|
||||
mov edi,DWORD [120+esp]
|
||||
mov DWORD [20+esp],ebx
|
||||
mov DWORD [24+esp],ebp
|
||||
mov DWORD [40+esp],ecx
|
||||
mov DWORD [44+esp],esi
|
||||
mov DWORD [52+esp],edx
|
||||
mov DWORD [56+esp],edi
|
||||
mov ebx,DWORD [92+esp]
|
||||
mov edi,DWORD [124+esp]
|
||||
mov edx,DWORD [112+esp]
|
||||
mov ebp,DWORD [80+esp]
|
||||
mov ecx,DWORD [96+esp]
|
||||
mov esi,DWORD [100+esp]
|
||||
add edx,1
|
||||
mov DWORD [28+esp],ebx
|
||||
mov DWORD [60+esp],edi
|
||||
mov DWORD [112+esp],edx
|
||||
mov ebx,10
|
||||
jmp NEAR L$004loop
|
||||
align 16
|
||||
L$004loop:
|
||||
add eax,ebp
|
||||
mov DWORD [128+esp],ebx
|
||||
mov ebx,ebp
|
||||
xor edx,eax
|
||||
rol edx,16
|
||||
add ecx,edx
|
||||
xor ebx,ecx
|
||||
mov edi,DWORD [52+esp]
|
||||
rol ebx,12
|
||||
mov ebp,DWORD [20+esp]
|
||||
add eax,ebx
|
||||
xor edx,eax
|
||||
mov DWORD [esp],eax
|
||||
rol edx,8
|
||||
mov eax,DWORD [4+esp]
|
||||
add ecx,edx
|
||||
mov DWORD [48+esp],edx
|
||||
xor ebx,ecx
|
||||
add eax,ebp
|
||||
rol ebx,7
|
||||
xor edi,eax
|
||||
mov DWORD [32+esp],ecx
|
||||
rol edi,16
|
||||
mov DWORD [16+esp],ebx
|
||||
add esi,edi
|
||||
mov ecx,DWORD [40+esp]
|
||||
xor ebp,esi
|
||||
mov edx,DWORD [56+esp]
|
||||
rol ebp,12
|
||||
mov ebx,DWORD [24+esp]
|
||||
add eax,ebp
|
||||
xor edi,eax
|
||||
mov DWORD [4+esp],eax
|
||||
rol edi,8
|
||||
mov eax,DWORD [8+esp]
|
||||
add esi,edi
|
||||
mov DWORD [52+esp],edi
|
||||
xor ebp,esi
|
||||
add eax,ebx
|
||||
rol ebp,7
|
||||
xor edx,eax
|
||||
mov DWORD [36+esp],esi
|
||||
rol edx,16
|
||||
mov DWORD [20+esp],ebp
|
||||
add ecx,edx
|
||||
mov esi,DWORD [44+esp]
|
||||
xor ebx,ecx
|
||||
mov edi,DWORD [60+esp]
|
||||
rol ebx,12
|
||||
mov ebp,DWORD [28+esp]
|
||||
add eax,ebx
|
||||
xor edx,eax
|
||||
mov DWORD [8+esp],eax
|
||||
rol edx,8
|
||||
mov eax,DWORD [12+esp]
|
||||
add ecx,edx
|
||||
mov DWORD [56+esp],edx
|
||||
xor ebx,ecx
|
||||
add eax,ebp
|
||||
rol ebx,7
|
||||
xor edi,eax
|
||||
rol edi,16
|
||||
mov DWORD [24+esp],ebx
|
||||
add esi,edi
|
||||
xor ebp,esi
|
||||
rol ebp,12
|
||||
mov ebx,DWORD [20+esp]
|
||||
add eax,ebp
|
||||
xor edi,eax
|
||||
mov DWORD [12+esp],eax
|
||||
rol edi,8
|
||||
mov eax,DWORD [esp]
|
||||
add esi,edi
|
||||
mov edx,edi
|
||||
xor ebp,esi
|
||||
add eax,ebx
|
||||
rol ebp,7
|
||||
xor edx,eax
|
||||
rol edx,16
|
||||
mov DWORD [28+esp],ebp
|
||||
add ecx,edx
|
||||
xor ebx,ecx
|
||||
mov edi,DWORD [48+esp]
|
||||
rol ebx,12
|
||||
mov ebp,DWORD [24+esp]
|
||||
add eax,ebx
|
||||
xor edx,eax
|
||||
mov DWORD [esp],eax
|
||||
rol edx,8
|
||||
mov eax,DWORD [4+esp]
|
||||
add ecx,edx
|
||||
mov DWORD [60+esp],edx
|
||||
xor ebx,ecx
|
||||
add eax,ebp
|
||||
rol ebx,7
|
||||
xor edi,eax
|
||||
mov DWORD [40+esp],ecx
|
||||
rol edi,16
|
||||
mov DWORD [20+esp],ebx
|
||||
add esi,edi
|
||||
mov ecx,DWORD [32+esp]
|
||||
xor ebp,esi
|
||||
mov edx,DWORD [52+esp]
|
||||
rol ebp,12
|
||||
mov ebx,DWORD [28+esp]
|
||||
add eax,ebp
|
||||
xor edi,eax
|
||||
mov DWORD [4+esp],eax
|
||||
rol edi,8
|
||||
mov eax,DWORD [8+esp]
|
||||
add esi,edi
|
||||
mov DWORD [48+esp],edi
|
||||
xor ebp,esi
|
||||
add eax,ebx
|
||||
rol ebp,7
|
||||
xor edx,eax
|
||||
mov DWORD [44+esp],esi
|
||||
rol edx,16
|
||||
mov DWORD [24+esp],ebp
|
||||
add ecx,edx
|
||||
mov esi,DWORD [36+esp]
|
||||
xor ebx,ecx
|
||||
mov edi,DWORD [56+esp]
|
||||
rol ebx,12
|
||||
mov ebp,DWORD [16+esp]
|
||||
add eax,ebx
|
||||
xor edx,eax
|
||||
mov DWORD [8+esp],eax
|
||||
rol edx,8
|
||||
mov eax,DWORD [12+esp]
|
||||
add ecx,edx
|
||||
mov DWORD [52+esp],edx
|
||||
xor ebx,ecx
|
||||
add eax,ebp
|
||||
rol ebx,7
|
||||
xor edi,eax
|
||||
rol edi,16
|
||||
mov DWORD [28+esp],ebx
|
||||
add esi,edi
|
||||
xor ebp,esi
|
||||
mov edx,DWORD [48+esp]
|
||||
rol ebp,12
|
||||
mov ebx,DWORD [128+esp]
|
||||
add eax,ebp
|
||||
xor edi,eax
|
||||
mov DWORD [12+esp],eax
|
||||
rol edi,8
|
||||
mov eax,DWORD [esp]
|
||||
add esi,edi
|
||||
mov DWORD [56+esp],edi
|
||||
xor ebp,esi
|
||||
rol ebp,7
|
||||
dec ebx
|
||||
jnz NEAR L$004loop
|
||||
mov ebx,DWORD [160+esp]
|
||||
add eax,1634760805
|
||||
add ebp,DWORD [80+esp]
|
||||
add ecx,DWORD [96+esp]
|
||||
add esi,DWORD [100+esp]
|
||||
cmp ebx,64
|
||||
jb NEAR L$005tail
|
||||
mov ebx,DWORD [156+esp]
|
||||
add edx,DWORD [112+esp]
|
||||
add edi,DWORD [120+esp]
|
||||
xor eax,DWORD [ebx]
|
||||
xor ebp,DWORD [16+ebx]
|
||||
mov DWORD [esp],eax
|
||||
mov eax,DWORD [152+esp]
|
||||
xor ecx,DWORD [32+ebx]
|
||||
xor esi,DWORD [36+ebx]
|
||||
xor edx,DWORD [48+ebx]
|
||||
xor edi,DWORD [56+ebx]
|
||||
mov DWORD [16+eax],ebp
|
||||
mov DWORD [32+eax],ecx
|
||||
mov DWORD [36+eax],esi
|
||||
mov DWORD [48+eax],edx
|
||||
mov DWORD [56+eax],edi
|
||||
mov ebp,DWORD [4+esp]
|
||||
mov ecx,DWORD [8+esp]
|
||||
mov esi,DWORD [12+esp]
|
||||
mov edx,DWORD [20+esp]
|
||||
mov edi,DWORD [24+esp]
|
||||
add ebp,857760878
|
||||
add ecx,2036477234
|
||||
add esi,1797285236
|
||||
add edx,DWORD [84+esp]
|
||||
add edi,DWORD [88+esp]
|
||||
xor ebp,DWORD [4+ebx]
|
||||
xor ecx,DWORD [8+ebx]
|
||||
xor esi,DWORD [12+ebx]
|
||||
xor edx,DWORD [20+ebx]
|
||||
xor edi,DWORD [24+ebx]
|
||||
mov DWORD [4+eax],ebp
|
||||
mov DWORD [8+eax],ecx
|
||||
mov DWORD [12+eax],esi
|
||||
mov DWORD [20+eax],edx
|
||||
mov DWORD [24+eax],edi
|
||||
mov ebp,DWORD [28+esp]
|
||||
mov ecx,DWORD [40+esp]
|
||||
mov esi,DWORD [44+esp]
|
||||
mov edx,DWORD [52+esp]
|
||||
mov edi,DWORD [60+esp]
|
||||
add ebp,DWORD [92+esp]
|
||||
add ecx,DWORD [104+esp]
|
||||
add esi,DWORD [108+esp]
|
||||
add edx,DWORD [116+esp]
|
||||
add edi,DWORD [124+esp]
|
||||
xor ebp,DWORD [28+ebx]
|
||||
xor ecx,DWORD [40+ebx]
|
||||
xor esi,DWORD [44+ebx]
|
||||
xor edx,DWORD [52+ebx]
|
||||
xor edi,DWORD [60+ebx]
|
||||
lea ebx,[64+ebx]
|
||||
mov DWORD [28+eax],ebp
|
||||
mov ebp,DWORD [esp]
|
||||
mov DWORD [40+eax],ecx
|
||||
mov ecx,DWORD [160+esp]
|
||||
mov DWORD [44+eax],esi
|
||||
mov DWORD [52+eax],edx
|
||||
mov DWORD [60+eax],edi
|
||||
mov DWORD [eax],ebp
|
||||
lea eax,[64+eax]
|
||||
sub ecx,64
|
||||
jnz NEAR L$003outer_loop
|
||||
jmp NEAR L$006done
|
||||
L$005tail:
|
||||
add edx,DWORD [112+esp]
|
||||
add edi,DWORD [120+esp]
|
||||
mov DWORD [esp],eax
|
||||
mov DWORD [16+esp],ebp
|
||||
mov DWORD [32+esp],ecx
|
||||
mov DWORD [36+esp],esi
|
||||
mov DWORD [48+esp],edx
|
||||
mov DWORD [56+esp],edi
|
||||
mov ebp,DWORD [4+esp]
|
||||
mov ecx,DWORD [8+esp]
|
||||
mov esi,DWORD [12+esp]
|
||||
mov edx,DWORD [20+esp]
|
||||
mov edi,DWORD [24+esp]
|
||||
add ebp,857760878
|
||||
add ecx,2036477234
|
||||
add esi,1797285236
|
||||
add edx,DWORD [84+esp]
|
||||
add edi,DWORD [88+esp]
|
||||
mov DWORD [4+esp],ebp
|
||||
mov DWORD [8+esp],ecx
|
||||
mov DWORD [12+esp],esi
|
||||
mov DWORD [20+esp],edx
|
||||
mov DWORD [24+esp],edi
|
||||
mov ebp,DWORD [28+esp]
|
||||
mov ecx,DWORD [40+esp]
|
||||
mov esi,DWORD [44+esp]
|
||||
mov edx,DWORD [52+esp]
|
||||
mov edi,DWORD [60+esp]
|
||||
add ebp,DWORD [92+esp]
|
||||
add ecx,DWORD [104+esp]
|
||||
add esi,DWORD [108+esp]
|
||||
add edx,DWORD [116+esp]
|
||||
add edi,DWORD [124+esp]
|
||||
mov DWORD [28+esp],ebp
|
||||
mov ebp,DWORD [156+esp]
|
||||
mov DWORD [40+esp],ecx
|
||||
mov ecx,DWORD [152+esp]
|
||||
mov DWORD [44+esp],esi
|
||||
xor esi,esi
|
||||
mov DWORD [52+esp],edx
|
||||
mov DWORD [60+esp],edi
|
||||
xor eax,eax
|
||||
xor edx,edx
|
||||
L$007tail_loop:
|
||||
mov al,BYTE [ebp*1+esi]
|
||||
mov dl,BYTE [esi*1+esp]
|
||||
lea esi,[1+esi]
|
||||
xor al,dl
|
||||
mov BYTE [esi*1+ecx-1],al
|
||||
dec ebx
|
||||
jnz NEAR L$007tail_loop
|
||||
L$006done:
|
||||
add esp,132
|
||||
L$000no_data:
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
global _ChaCha20_ssse3
|
||||
align 16
|
||||
_ChaCha20_ssse3:
|
||||
L$_ChaCha20_ssse3_begin:
|
||||
push ebp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
L$ssse3_shortcut:
|
||||
mov edi,DWORD [20+esp]
|
||||
mov esi,DWORD [24+esp]
|
||||
mov ecx,DWORD [28+esp]
|
||||
mov edx,DWORD [32+esp]
|
||||
mov ebx,DWORD [36+esp]
|
||||
mov ebp,esp
|
||||
sub esp,524
|
||||
and esp,-64
|
||||
mov DWORD [512+esp],ebp
|
||||
lea eax,[(L$ssse3_data-L$pic_point)+eax]
|
||||
movdqu xmm3,[ebx]
|
||||
cmp ecx,256
|
||||
jb NEAR L$0081x
|
||||
mov DWORD [516+esp],edx
|
||||
mov DWORD [520+esp],ebx
|
||||
sub ecx,256
|
||||
lea ebp,[384+esp]
|
||||
movdqu xmm7,[edx]
|
||||
pshufd xmm0,xmm3,0
|
||||
pshufd xmm1,xmm3,85
|
||||
pshufd xmm2,xmm3,170
|
||||
pshufd xmm3,xmm3,255
|
||||
paddd xmm0,[48+eax]
|
||||
pshufd xmm4,xmm7,0
|
||||
pshufd xmm5,xmm7,85
|
||||
psubd xmm0,[64+eax]
|
||||
pshufd xmm6,xmm7,170
|
||||
pshufd xmm7,xmm7,255
|
||||
movdqa [64+ebp],xmm0
|
||||
movdqa [80+ebp],xmm1
|
||||
movdqa [96+ebp],xmm2
|
||||
movdqa [112+ebp],xmm3
|
||||
movdqu xmm3,[16+edx]
|
||||
movdqa [ebp-64],xmm4
|
||||
movdqa [ebp-48],xmm5
|
||||
movdqa [ebp-32],xmm6
|
||||
movdqa [ebp-16],xmm7
|
||||
movdqa xmm7,[32+eax]
|
||||
lea ebx,[128+esp]
|
||||
pshufd xmm0,xmm3,0
|
||||
pshufd xmm1,xmm3,85
|
||||
pshufd xmm2,xmm3,170
|
||||
pshufd xmm3,xmm3,255
|
||||
pshufd xmm4,xmm7,0
|
||||
pshufd xmm5,xmm7,85
|
||||
pshufd xmm6,xmm7,170
|
||||
pshufd xmm7,xmm7,255
|
||||
movdqa [ebp],xmm0
|
||||
movdqa [16+ebp],xmm1
|
||||
movdqa [32+ebp],xmm2
|
||||
movdqa [48+ebp],xmm3
|
||||
movdqa [ebp-128],xmm4
|
||||
movdqa [ebp-112],xmm5
|
||||
movdqa [ebp-96],xmm6
|
||||
movdqa [ebp-80],xmm7
|
||||
lea esi,[128+esi]
|
||||
lea edi,[128+edi]
|
||||
jmp NEAR L$009outer_loop
|
||||
align 16
|
||||
L$009outer_loop:
|
||||
movdqa xmm1,[ebp-112]
|
||||
movdqa xmm2,[ebp-96]
|
||||
movdqa xmm3,[ebp-80]
|
||||
movdqa xmm5,[ebp-48]
|
||||
movdqa xmm6,[ebp-32]
|
||||
movdqa xmm7,[ebp-16]
|
||||
movdqa [ebx-112],xmm1
|
||||
movdqa [ebx-96],xmm2
|
||||
movdqa [ebx-80],xmm3
|
||||
movdqa [ebx-48],xmm5
|
||||
movdqa [ebx-32],xmm6
|
||||
movdqa [ebx-16],xmm7
|
||||
movdqa xmm2,[32+ebp]
|
||||
movdqa xmm3,[48+ebp]
|
||||
movdqa xmm4,[64+ebp]
|
||||
movdqa xmm5,[80+ebp]
|
||||
movdqa xmm6,[96+ebp]
|
||||
movdqa xmm7,[112+ebp]
|
||||
paddd xmm4,[64+eax]
|
||||
movdqa [32+ebx],xmm2
|
||||
movdqa [48+ebx],xmm3
|
||||
movdqa [64+ebx],xmm4
|
||||
movdqa [80+ebx],xmm5
|
||||
movdqa [96+ebx],xmm6
|
||||
movdqa [112+ebx],xmm7
|
||||
movdqa [64+ebp],xmm4
|
||||
movdqa xmm0,[ebp-128]
|
||||
movdqa xmm6,xmm4
|
||||
movdqa xmm3,[ebp-64]
|
||||
movdqa xmm4,[ebp]
|
||||
movdqa xmm5,[16+ebp]
|
||||
mov edx,10
|
||||
nop
|
||||
align 16
|
||||
L$010loop:
|
||||
paddd xmm0,xmm3
|
||||
movdqa xmm2,xmm3
|
||||
pxor xmm6,xmm0
|
||||
pshufb xmm6,[eax]
|
||||
paddd xmm4,xmm6
|
||||
pxor xmm2,xmm4
|
||||
movdqa xmm3,[ebx-48]
|
||||
movdqa xmm1,xmm2
|
||||
pslld xmm2,12
|
||||
psrld xmm1,20
|
||||
por xmm2,xmm1
|
||||
movdqa xmm1,[ebx-112]
|
||||
paddd xmm0,xmm2
|
||||
movdqa xmm7,[80+ebx]
|
||||
pxor xmm6,xmm0
|
||||
movdqa [ebx-128],xmm0
|
||||
pshufb xmm6,[16+eax]
|
||||
paddd xmm4,xmm6
|
||||
movdqa [64+ebx],xmm6
|
||||
pxor xmm2,xmm4
|
||||
paddd xmm1,xmm3
|
||||
movdqa xmm0,xmm2
|
||||
pslld xmm2,7
|
||||
psrld xmm0,25
|
||||
pxor xmm7,xmm1
|
||||
por xmm2,xmm0
|
||||
movdqa [ebx],xmm4
|
||||
pshufb xmm7,[eax]
|
||||
movdqa [ebx-64],xmm2
|
||||
paddd xmm5,xmm7
|
||||
movdqa xmm4,[32+ebx]
|
||||
pxor xmm3,xmm5
|
||||
movdqa xmm2,[ebx-32]
|
||||
movdqa xmm0,xmm3
|
||||
pslld xmm3,12
|
||||
psrld xmm0,20
|
||||
por xmm3,xmm0
|
||||
movdqa xmm0,[ebx-96]
|
||||
paddd xmm1,xmm3
|
||||
movdqa xmm6,[96+ebx]
|
||||
pxor xmm7,xmm1
|
||||
movdqa [ebx-112],xmm1
|
||||
pshufb xmm7,[16+eax]
|
||||
paddd xmm5,xmm7
|
||||
movdqa [80+ebx],xmm7
|
||||
pxor xmm3,xmm5
|
||||
paddd xmm0,xmm2
|
||||
movdqa xmm1,xmm3
|
||||
pslld xmm3,7
|
||||
psrld xmm1,25
|
||||
pxor xmm6,xmm0
|
||||
por xmm3,xmm1
|
||||
movdqa [16+ebx],xmm5
|
||||
pshufb xmm6,[eax]
|
||||
movdqa [ebx-48],xmm3
|
||||
paddd xmm4,xmm6
|
||||
movdqa xmm5,[48+ebx]
|
||||
pxor xmm2,xmm4
|
||||
movdqa xmm3,[ebx-16]
|
||||
movdqa xmm1,xmm2
|
||||
pslld xmm2,12
|
||||
psrld xmm1,20
|
||||
por xmm2,xmm1
|
||||
movdqa xmm1,[ebx-80]
|
||||
paddd xmm0,xmm2
|
||||
movdqa xmm7,[112+ebx]
|
||||
pxor xmm6,xmm0
|
||||
movdqa [ebx-96],xmm0
|
||||
pshufb xmm6,[16+eax]
|
||||
paddd xmm4,xmm6
|
||||
movdqa [96+ebx],xmm6
|
||||
pxor xmm2,xmm4
|
||||
paddd xmm1,xmm3
|
||||
movdqa xmm0,xmm2
|
||||
pslld xmm2,7
|
||||
psrld xmm0,25
|
||||
pxor xmm7,xmm1
|
||||
por xmm2,xmm0
|
||||
pshufb xmm7,[eax]
|
||||
movdqa [ebx-32],xmm2
|
||||
paddd xmm5,xmm7
|
||||
pxor xmm3,xmm5
|
||||
movdqa xmm2,[ebx-48]
|
||||
movdqa xmm0,xmm3
|
||||
pslld xmm3,12
|
||||
psrld xmm0,20
|
||||
por xmm3,xmm0
|
||||
movdqa xmm0,[ebx-128]
|
||||
paddd xmm1,xmm3
|
||||
pxor xmm7,xmm1
|
||||
movdqa [ebx-80],xmm1
|
||||
pshufb xmm7,[16+eax]
|
||||
paddd xmm5,xmm7
|
||||
movdqa xmm6,xmm7
|
||||
pxor xmm3,xmm5
|
||||
paddd xmm0,xmm2
|
||||
movdqa xmm1,xmm3
|
||||
pslld xmm3,7
|
||||
psrld xmm1,25
|
||||
pxor xmm6,xmm0
|
||||
por xmm3,xmm1
|
||||
pshufb xmm6,[eax]
|
||||
movdqa [ebx-16],xmm3
|
||||
paddd xmm4,xmm6
|
||||
pxor xmm2,xmm4
|
||||
movdqa xmm3,[ebx-32]
|
||||
movdqa xmm1,xmm2
|
||||
pslld xmm2,12
|
||||
psrld xmm1,20
|
||||
por xmm2,xmm1
|
||||
movdqa xmm1,[ebx-112]
|
||||
paddd xmm0,xmm2
|
||||
movdqa xmm7,[64+ebx]
|
||||
pxor xmm6,xmm0
|
||||
movdqa [ebx-128],xmm0
|
||||
pshufb xmm6,[16+eax]
|
||||
paddd xmm4,xmm6
|
||||
movdqa [112+ebx],xmm6
|
||||
pxor xmm2,xmm4
|
||||
paddd xmm1,xmm3
|
||||
movdqa xmm0,xmm2
|
||||
pslld xmm2,7
|
||||
psrld xmm0,25
|
||||
pxor xmm7,xmm1
|
||||
por xmm2,xmm0
|
||||
movdqa [32+ebx],xmm4
|
||||
pshufb xmm7,[eax]
|
||||
movdqa [ebx-48],xmm2
|
||||
paddd xmm5,xmm7
|
||||
movdqa xmm4,[ebx]
|
||||
pxor xmm3,xmm5
|
||||
movdqa xmm2,[ebx-16]
|
||||
movdqa xmm0,xmm3
|
||||
pslld xmm3,12
|
||||
psrld xmm0,20
|
||||
por xmm3,xmm0
|
||||
movdqa xmm0,[ebx-96]
|
||||
paddd xmm1,xmm3
|
||||
movdqa xmm6,[80+ebx]
|
||||
pxor xmm7,xmm1
|
||||
movdqa [ebx-112],xmm1
|
||||
pshufb xmm7,[16+eax]
|
||||
paddd xmm5,xmm7
|
||||
movdqa [64+ebx],xmm7
|
||||
pxor xmm3,xmm5
|
||||
paddd xmm0,xmm2
|
||||
movdqa xmm1,xmm3
|
||||
pslld xmm3,7
|
||||
psrld xmm1,25
|
||||
pxor xmm6,xmm0
|
||||
por xmm3,xmm1
|
||||
movdqa [48+ebx],xmm5
|
||||
pshufb xmm6,[eax]
|
||||
movdqa [ebx-32],xmm3
|
||||
paddd xmm4,xmm6
|
||||
movdqa xmm5,[16+ebx]
|
||||
pxor xmm2,xmm4
|
||||
movdqa xmm3,[ebx-64]
|
||||
movdqa xmm1,xmm2
|
||||
pslld xmm2,12
|
||||
psrld xmm1,20
|
||||
por xmm2,xmm1
|
||||
movdqa xmm1,[ebx-80]
|
||||
paddd xmm0,xmm2
|
||||
movdqa xmm7,[96+ebx]
|
||||
pxor xmm6,xmm0
|
||||
movdqa [ebx-96],xmm0
|
||||
pshufb xmm6,[16+eax]
|
||||
paddd xmm4,xmm6
|
||||
movdqa [80+ebx],xmm6
|
||||
pxor xmm2,xmm4
|
||||
paddd xmm1,xmm3
|
||||
movdqa xmm0,xmm2
|
||||
pslld xmm2,7
|
||||
psrld xmm0,25
|
||||
pxor xmm7,xmm1
|
||||
por xmm2,xmm0
|
||||
pshufb xmm7,[eax]
|
||||
movdqa [ebx-16],xmm2
|
||||
paddd xmm5,xmm7
|
||||
pxor xmm3,xmm5
|
||||
movdqa xmm0,xmm3
|
||||
pslld xmm3,12
|
||||
psrld xmm0,20
|
||||
por xmm3,xmm0
|
||||
movdqa xmm0,[ebx-128]
|
||||
paddd xmm1,xmm3
|
||||
movdqa xmm6,[64+ebx]
|
||||
pxor xmm7,xmm1
|
||||
movdqa [ebx-80],xmm1
|
||||
pshufb xmm7,[16+eax]
|
||||
paddd xmm5,xmm7
|
||||
movdqa [96+ebx],xmm7
|
||||
pxor xmm3,xmm5
|
||||
movdqa xmm1,xmm3
|
||||
pslld xmm3,7
|
||||
psrld xmm1,25
|
||||
por xmm3,xmm1
|
||||
dec edx
|
||||
jnz NEAR L$010loop
|
||||
movdqa [ebx-64],xmm3
|
||||
movdqa [ebx],xmm4
|
||||
movdqa [16+ebx],xmm5
|
||||
movdqa [64+ebx],xmm6
|
||||
movdqa [96+ebx],xmm7
|
||||
movdqa xmm1,[ebx-112]
|
||||
movdqa xmm2,[ebx-96]
|
||||
movdqa xmm3,[ebx-80]
|
||||
paddd xmm0,[ebp-128]
|
||||
paddd xmm1,[ebp-112]
|
||||
paddd xmm2,[ebp-96]
|
||||
paddd xmm3,[ebp-80]
|
||||
movdqa xmm6,xmm0
|
||||
punpckldq xmm0,xmm1
|
||||
movdqa xmm7,xmm2
|
||||
punpckldq xmm2,xmm3
|
||||
punpckhdq xmm6,xmm1
|
||||
punpckhdq xmm7,xmm3
|
||||
movdqa xmm1,xmm0
|
||||
punpcklqdq xmm0,xmm2
|
||||
movdqa xmm3,xmm6
|
||||
punpcklqdq xmm6,xmm7
|
||||
punpckhqdq xmm1,xmm2
|
||||
punpckhqdq xmm3,xmm7
|
||||
movdqu xmm4,[esi-128]
|
||||
movdqu xmm5,[esi-64]
|
||||
movdqu xmm2,[esi]
|
||||
movdqu xmm7,[64+esi]
|
||||
lea esi,[16+esi]
|
||||
pxor xmm4,xmm0
|
||||
movdqa xmm0,[ebx-64]
|
||||
pxor xmm5,xmm1
|
||||
movdqa xmm1,[ebx-48]
|
||||
pxor xmm6,xmm2
|
||||
movdqa xmm2,[ebx-32]
|
||||
pxor xmm7,xmm3
|
||||
movdqa xmm3,[ebx-16]
|
||||
movdqu [edi-128],xmm4
|
||||
movdqu [edi-64],xmm5
|
||||
movdqu [edi],xmm6
|
||||
movdqu [64+edi],xmm7
|
||||
lea edi,[16+edi]
|
||||
paddd xmm0,[ebp-64]
|
||||
paddd xmm1,[ebp-48]
|
||||
paddd xmm2,[ebp-32]
|
||||
paddd xmm3,[ebp-16]
|
||||
movdqa xmm6,xmm0
|
||||
punpckldq xmm0,xmm1
|
||||
movdqa xmm7,xmm2
|
||||
punpckldq xmm2,xmm3
|
||||
punpckhdq xmm6,xmm1
|
||||
punpckhdq xmm7,xmm3
|
||||
movdqa xmm1,xmm0
|
||||
punpcklqdq xmm0,xmm2
|
||||
movdqa xmm3,xmm6
|
||||
punpcklqdq xmm6,xmm7
|
||||
punpckhqdq xmm1,xmm2
|
||||
punpckhqdq xmm3,xmm7
|
||||
movdqu xmm4,[esi-128]
|
||||
movdqu xmm5,[esi-64]
|
||||
movdqu xmm2,[esi]
|
||||
movdqu xmm7,[64+esi]
|
||||
lea esi,[16+esi]
|
||||
pxor xmm4,xmm0
|
||||
movdqa xmm0,[ebx]
|
||||
pxor xmm5,xmm1
|
||||
movdqa xmm1,[16+ebx]
|
||||
pxor xmm6,xmm2
|
||||
movdqa xmm2,[32+ebx]
|
||||
pxor xmm7,xmm3
|
||||
movdqa xmm3,[48+ebx]
|
||||
movdqu [edi-128],xmm4
|
||||
movdqu [edi-64],xmm5
|
||||
movdqu [edi],xmm6
|
||||
movdqu [64+edi],xmm7
|
||||
lea edi,[16+edi]
|
||||
paddd xmm0,[ebp]
|
||||
paddd xmm1,[16+ebp]
|
||||
paddd xmm2,[32+ebp]
|
||||
paddd xmm3,[48+ebp]
|
||||
movdqa xmm6,xmm0
|
||||
punpckldq xmm0,xmm1
|
||||
movdqa xmm7,xmm2
|
||||
punpckldq xmm2,xmm3
|
||||
punpckhdq xmm6,xmm1
|
||||
punpckhdq xmm7,xmm3
|
||||
movdqa xmm1,xmm0
|
||||
punpcklqdq xmm0,xmm2
|
||||
movdqa xmm3,xmm6
|
||||
punpcklqdq xmm6,xmm7
|
||||
punpckhqdq xmm1,xmm2
|
||||
punpckhqdq xmm3,xmm7
|
||||
movdqu xmm4,[esi-128]
|
||||
movdqu xmm5,[esi-64]
|
||||
movdqu xmm2,[esi]
|
||||
movdqu xmm7,[64+esi]
|
||||
lea esi,[16+esi]
|
||||
pxor xmm4,xmm0
|
||||
movdqa xmm0,[64+ebx]
|
||||
pxor xmm5,xmm1
|
||||
movdqa xmm1,[80+ebx]
|
||||
pxor xmm6,xmm2
|
||||
movdqa xmm2,[96+ebx]
|
||||
pxor xmm7,xmm3
|
||||
movdqa xmm3,[112+ebx]
|
||||
movdqu [edi-128],xmm4
|
||||
movdqu [edi-64],xmm5
|
||||
movdqu [edi],xmm6
|
||||
movdqu [64+edi],xmm7
|
||||
lea edi,[16+edi]
|
||||
paddd xmm0,[64+ebp]
|
||||
paddd xmm1,[80+ebp]
|
||||
paddd xmm2,[96+ebp]
|
||||
paddd xmm3,[112+ebp]
|
||||
movdqa xmm6,xmm0
|
||||
punpckldq xmm0,xmm1
|
||||
movdqa xmm7,xmm2
|
||||
punpckldq xmm2,xmm3
|
||||
punpckhdq xmm6,xmm1
|
||||
punpckhdq xmm7,xmm3
|
||||
movdqa xmm1,xmm0
|
||||
punpcklqdq xmm0,xmm2
|
||||
movdqa xmm3,xmm6
|
||||
punpcklqdq xmm6,xmm7
|
||||
punpckhqdq xmm1,xmm2
|
||||
punpckhqdq xmm3,xmm7
|
||||
movdqu xmm4,[esi-128]
|
||||
movdqu xmm5,[esi-64]
|
||||
movdqu xmm2,[esi]
|
||||
movdqu xmm7,[64+esi]
|
||||
lea esi,[208+esi]
|
||||
pxor xmm4,xmm0
|
||||
pxor xmm5,xmm1
|
||||
pxor xmm6,xmm2
|
||||
pxor xmm7,xmm3
|
||||
movdqu [edi-128],xmm4
|
||||
movdqu [edi-64],xmm5
|
||||
movdqu [edi],xmm6
|
||||
movdqu [64+edi],xmm7
|
||||
lea edi,[208+edi]
|
||||
sub ecx,256
|
||||
jnc NEAR L$009outer_loop
|
||||
add ecx,256
|
||||
jz NEAR L$011done
|
||||
mov ebx,DWORD [520+esp]
|
||||
lea esi,[esi-128]
|
||||
mov edx,DWORD [516+esp]
|
||||
lea edi,[edi-128]
|
||||
movd xmm2,DWORD [64+ebp]
|
||||
movdqu xmm3,[ebx]
|
||||
paddd xmm2,[96+eax]
|
||||
pand xmm3,[112+eax]
|
||||
por xmm3,xmm2
|
||||
L$0081x:
|
||||
movdqa xmm0,[32+eax]
|
||||
movdqu xmm1,[edx]
|
||||
movdqu xmm2,[16+edx]
|
||||
movdqa xmm6,[eax]
|
||||
movdqa xmm7,[16+eax]
|
||||
mov DWORD [48+esp],ebp
|
||||
movdqa [esp],xmm0
|
||||
movdqa [16+esp],xmm1
|
||||
movdqa [32+esp],xmm2
|
||||
movdqa [48+esp],xmm3
|
||||
mov edx,10
|
||||
jmp NEAR L$012loop1x
|
||||
align 16
|
||||
L$013outer1x:
|
||||
movdqa xmm3,[80+eax]
|
||||
movdqa xmm0,[esp]
|
||||
movdqa xmm1,[16+esp]
|
||||
movdqa xmm2,[32+esp]
|
||||
paddd xmm3,[48+esp]
|
||||
mov edx,10
|
||||
movdqa [48+esp],xmm3
|
||||
jmp NEAR L$012loop1x
|
||||
align 16
|
||||
L$012loop1x:
|
||||
paddd xmm0,xmm1
|
||||
pxor xmm3,xmm0
|
||||
db 102,15,56,0,222
|
||||
paddd xmm2,xmm3
|
||||
pxor xmm1,xmm2
|
||||
movdqa xmm4,xmm1
|
||||
psrld xmm1,20
|
||||
pslld xmm4,12
|
||||
por xmm1,xmm4
|
||||
paddd xmm0,xmm1
|
||||
pxor xmm3,xmm0
|
||||
db 102,15,56,0,223
|
||||
paddd xmm2,xmm3
|
||||
pxor xmm1,xmm2
|
||||
movdqa xmm4,xmm1
|
||||
psrld xmm1,25
|
||||
pslld xmm4,7
|
||||
por xmm1,xmm4
|
||||
pshufd xmm2,xmm2,78
|
||||
pshufd xmm1,xmm1,57
|
||||
pshufd xmm3,xmm3,147
|
||||
nop
|
||||
paddd xmm0,xmm1
|
||||
pxor xmm3,xmm0
|
||||
db 102,15,56,0,222
|
||||
paddd xmm2,xmm3
|
||||
pxor xmm1,xmm2
|
||||
movdqa xmm4,xmm1
|
||||
psrld xmm1,20
|
||||
pslld xmm4,12
|
||||
por xmm1,xmm4
|
||||
paddd xmm0,xmm1
|
||||
pxor xmm3,xmm0
|
||||
db 102,15,56,0,223
|
||||
paddd xmm2,xmm3
|
||||
pxor xmm1,xmm2
|
||||
movdqa xmm4,xmm1
|
||||
psrld xmm1,25
|
||||
pslld xmm4,7
|
||||
por xmm1,xmm4
|
||||
pshufd xmm2,xmm2,78
|
||||
pshufd xmm1,xmm1,147
|
||||
pshufd xmm3,xmm3,57
|
||||
dec edx
|
||||
jnz NEAR L$012loop1x
|
||||
paddd xmm0,[esp]
|
||||
paddd xmm1,[16+esp]
|
||||
paddd xmm2,[32+esp]
|
||||
paddd xmm3,[48+esp]
|
||||
cmp ecx,64
|
||||
jb NEAR L$014tail
|
||||
movdqu xmm4,[esi]
|
||||
movdqu xmm5,[16+esi]
|
||||
pxor xmm0,xmm4
|
||||
movdqu xmm4,[32+esi]
|
||||
pxor xmm1,xmm5
|
||||
movdqu xmm5,[48+esi]
|
||||
pxor xmm2,xmm4
|
||||
pxor xmm3,xmm5
|
||||
lea esi,[64+esi]
|
||||
movdqu [edi],xmm0
|
||||
movdqu [16+edi],xmm1
|
||||
movdqu [32+edi],xmm2
|
||||
movdqu [48+edi],xmm3
|
||||
lea edi,[64+edi]
|
||||
sub ecx,64
|
||||
jnz NEAR L$013outer1x
|
||||
jmp NEAR L$011done
|
||||
L$014tail:
|
||||
movdqa [esp],xmm0
|
||||
movdqa [16+esp],xmm1
|
||||
movdqa [32+esp],xmm2
|
||||
movdqa [48+esp],xmm3
|
||||
xor eax,eax
|
||||
xor edx,edx
|
||||
xor ebp,ebp
|
||||
L$015tail_loop:
|
||||
mov al,BYTE [ebp*1+esp]
|
||||
mov dl,BYTE [ebp*1+esi]
|
||||
lea ebp,[1+ebp]
|
||||
xor al,dl
|
||||
mov BYTE [ebp*1+edi-1],al
|
||||
dec ecx
|
||||
jnz NEAR L$015tail_loop
|
||||
L$011done:
|
||||
mov esp,DWORD [512+esp]
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
align 64
|
||||
L$ssse3_data:
|
||||
db 2,3,0,1,6,7,4,5,10,11,8,9,14,15,12,13
|
||||
db 3,0,1,2,7,4,5,6,11,8,9,10,15,12,13,14
|
||||
dd 1634760805,857760878,2036477234,1797285236
|
||||
dd 0,1,2,3
|
||||
dd 4,4,4,4
|
||||
dd 1,0,0,0
|
||||
dd 4,0,0,0
|
||||
dd 0,-1,-1,-1
|
||||
align 64
|
||||
db 67,104,97,67,104,97,50,48,32,102,111,114,32,120,56,54
|
||||
db 44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32
|
||||
db 60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111
|
||||
db 114,103,62,0
|
||||
segment .bss
|
||||
common _OPENSSL_ia32cap_P 16
|
||||
%else
|
||||
; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738
|
||||
ret
|
||||
%endif
|
||||
#endif // defined(__i386__) && defined(_WIN32)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
+35
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2014, Google Inc.
|
||||
/* Copyright 2014 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -60,7 +60,40 @@ void CRYPTO_hchacha20(uint8_t out[32], const uint8_t key[32],
|
||||
OPENSSL_memcpy(&out[16], &x[12], sizeof(uint32_t) * 4);
|
||||
}
|
||||
|
||||
#if defined(CHACHA20_ASM)
|
||||
#if defined(CHACHA20_ASM_NOHW)
|
||||
static void ChaCha20_ctr32(uint8_t *out, const uint8_t *in, size_t in_len,
|
||||
const uint32_t key[8], const uint32_t counter[4]) {
|
||||
#if defined(CHACHA20_ASM_NEON)
|
||||
if (ChaCha20_ctr32_neon_capable(in_len)) {
|
||||
ChaCha20_ctr32_neon(out, in, in_len, key, counter);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if defined(CHACHA20_ASM_AVX2)
|
||||
if (ChaCha20_ctr32_avx2_capable(in_len)) {
|
||||
ChaCha20_ctr32_avx2(out, in, in_len, key, counter);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if defined(CHACHA20_ASM_SSSE3_4X)
|
||||
if (ChaCha20_ctr32_ssse3_4x_capable(in_len)) {
|
||||
ChaCha20_ctr32_ssse3_4x(out, in, in_len, key, counter);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if defined(CHACHA20_ASM_SSSE3)
|
||||
if (ChaCha20_ctr32_ssse3_capable(in_len)) {
|
||||
ChaCha20_ctr32_ssse3(out, in, in_len, key, counter);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (in_len > 0) {
|
||||
ChaCha20_ctr32_nohw(out, in, in_len, key, counter);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CHACHA20_ASM_NOHW)
|
||||
|
||||
void CRYPTO_chacha_20(uint8_t *out, const uint8_t *in, size_t in_len,
|
||||
const uint8_t key[32], const uint8_t nonce[12],
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2018, Google Inc.
|
||||
/* Copyright 2018 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
|
||||
#include "../internal.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -27,21 +29,69 @@ extern "C" {
|
||||
void CRYPTO_hchacha20(uint8_t out[32], const uint8_t key[32],
|
||||
const uint8_t nonce[16]);
|
||||
|
||||
#if !defined(OPENSSL_NO_ASM) && \
|
||||
(defined(OPENSSL_X86) || defined(OPENSSL_X86_64) || \
|
||||
defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64))
|
||||
#define CHACHA20_ASM
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86)
|
||||
|
||||
// ChaCha20_ctr32 encrypts |in_len| bytes from |in| and writes the result to
|
||||
// |out|. If |in| and |out| alias, they must be equal.
|
||||
#define CHACHA20_ASM_NOHW
|
||||
|
||||
#define CHACHA20_ASM_SSSE3
|
||||
OPENSSL_INLINE int ChaCha20_ctr32_ssse3_capable(size_t len) {
|
||||
// Unlike the x86_64 version, the x86 SSSE3 routine runs for all non-zero
|
||||
// lengths.
|
||||
return len > 0 && CRYPTO_is_SSSE3_capable() && CRYPTO_is_FXSR_capable();
|
||||
}
|
||||
void ChaCha20_ctr32_ssse3(uint8_t *out, const uint8_t *in, size_t in_len,
|
||||
const uint32_t key[8], const uint32_t counter[4]);
|
||||
|
||||
#elif !defined(OPENSSL_NO_ASM) && \
|
||||
(defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64))
|
||||
|
||||
#define CHACHA20_ASM_NOHW
|
||||
|
||||
#define CHACHA20_ASM_NEON
|
||||
OPENSSL_INLINE int ChaCha20_ctr32_neon_capable(size_t len) {
|
||||
return len >= 192 && CRYPTO_is_NEON_capable();
|
||||
}
|
||||
void ChaCha20_ctr32_neon(uint8_t *out, const uint8_t *in, size_t in_len,
|
||||
const uint32_t key[8], const uint32_t counter[4]);
|
||||
#elif !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64)
|
||||
#define CHACHA20_ASM_NOHW
|
||||
|
||||
#define CHACHA20_ASM_AVX2
|
||||
OPENSSL_INLINE int ChaCha20_ctr32_avx2_capable(size_t len) {
|
||||
return len > 128 && CRYPTO_is_AVX2_capable();
|
||||
}
|
||||
void ChaCha20_ctr32_avx2(uint8_t *out, const uint8_t *in, size_t in_len,
|
||||
const uint32_t key[8], const uint32_t counter[4]);
|
||||
|
||||
#define CHACHA20_ASM_SSSE3_4X
|
||||
OPENSSL_INLINE int ChaCha20_ctr32_ssse3_4x_capable(size_t len) {
|
||||
int capable = len > 128 && CRYPTO_is_SSSE3_capable();
|
||||
int faster = len > 192 || !CRYPTO_cpu_perf_is_like_silvermont();
|
||||
return capable && faster;
|
||||
}
|
||||
void ChaCha20_ctr32_ssse3_4x(uint8_t *out, const uint8_t *in, size_t in_len,
|
||||
const uint32_t key[8], const uint32_t counter[4]);
|
||||
|
||||
#define CHACHA20_ASM_SSSE3
|
||||
OPENSSL_INLINE int ChaCha20_ctr32_ssse3_capable(size_t len) {
|
||||
return len > 128 && CRYPTO_is_SSSE3_capable();
|
||||
}
|
||||
void ChaCha20_ctr32_ssse3(uint8_t *out, const uint8_t *in, size_t in_len,
|
||||
const uint32_t key[8], const uint32_t counter[4]);
|
||||
#endif
|
||||
|
||||
#if defined(CHACHA20_ASM_NOHW)
|
||||
// ChaCha20_ctr32_nohw encrypts |in_len| bytes from |in| and writes the result
|
||||
// to |out|. If |in| and |out| alias, they must be equal. |in_len| may not be
|
||||
// zero.
|
||||
//
|
||||
// |counter[0]| is the initial 32-bit block counter, and the remainder is the
|
||||
// 96-bit nonce. If the counter overflows, the output is undefined. The function
|
||||
// will produce output, but the output may vary by machine and may not be
|
||||
// self-consistent. (On some architectures, the assembly implements a mix of
|
||||
// 64-bit and 32-bit counters.)
|
||||
void ChaCha20_ctr32(uint8_t *out, const uint8_t *in, size_t in_len,
|
||||
const uint32_t key[8], const uint32_t counter[4]);
|
||||
void ChaCha20_ctr32_nohw(uint8_t *out, const uint8_t *in, size_t in_len,
|
||||
const uint32_t key[8], const uint32_t counter[4]);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2017, Google Inc.
|
||||
/* Copyright 2017 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
+51
-66
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2017, Google Inc.
|
||||
/* Copyright 2017 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -36,7 +36,7 @@
|
||||
// Optimised AES-GCM-SIV
|
||||
|
||||
struct aead_aes_gcm_siv_asm_ctx {
|
||||
alignas(16) uint8_t key[16*15];
|
||||
alignas(16) uint8_t key[16 * 15];
|
||||
int is_128_bit;
|
||||
};
|
||||
|
||||
@@ -57,15 +57,17 @@ static struct aead_aes_gcm_siv_asm_ctx *asm_ctx_from_ctx(
|
||||
return (struct aead_aes_gcm_siv_asm_ctx *)(&ctx->state.opaque[offset]);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
// aes128gcmsiv_aes_ks writes an AES-128 key schedule for |key| to
|
||||
// |out_expanded_key|.
|
||||
extern void aes128gcmsiv_aes_ks(
|
||||
const uint8_t key[16], uint8_t out_expanded_key[16*15]);
|
||||
extern void aes128gcmsiv_aes_ks(const uint8_t key[16],
|
||||
uint8_t out_expanded_key[16 * 15]);
|
||||
|
||||
// aes256gcmsiv_aes_ks writes an AES-256 key schedule for |key| to
|
||||
// |out_expanded_key|.
|
||||
extern void aes256gcmsiv_aes_ks(
|
||||
const uint8_t key[32], uint8_t out_expanded_key[16*15]);
|
||||
extern void aes256gcmsiv_aes_ks(const uint8_t key[32],
|
||||
uint8_t out_expanded_key[16 * 15]);
|
||||
}
|
||||
|
||||
static int aead_aes_gcm_siv_asm_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
|
||||
size_t key_len, size_t tag_len) {
|
||||
@@ -103,6 +105,7 @@ static int aead_aes_gcm_siv_asm_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
|
||||
|
||||
static void aead_aes_gcm_siv_asm_cleanup(EVP_AEAD_CTX *ctx) {}
|
||||
|
||||
extern "C" {
|
||||
// aesgcmsiv_polyval_horner updates the POLYVAL value in |in_out_poly| to
|
||||
// include a number (|in_blocks|) of 16-byte blocks of data from |in|, given
|
||||
// the POLYVAL key in |key|.
|
||||
@@ -126,16 +129,16 @@ extern void aesgcmsiv_htable_polyval(const uint8_t htable[16 * 8],
|
||||
uint8_t in_out_poly[16]);
|
||||
|
||||
// aes128gcmsiv_dec decrypts |in_len| & ~15 bytes from |out| and writes them to
|
||||
// |in|. (The full value of |in_len| is still used to find the authentication
|
||||
// tag appended to the ciphertext, however, so must not be pre-masked.)
|
||||
// |in|. |in| and |out| may be equal, but must not otherwise alias.
|
||||
//
|
||||
// |in| and |out| may be equal, but must not otherwise overlap.
|
||||
// |in_out_calculated_tag_and_scratch|, on entry, must contain:
|
||||
// 1. The current value of the calculated tag, which will be updated during
|
||||
// decryption and written back to the beginning of this buffer on exit.
|
||||
// 2. The claimed tag, which is needed to derive counter values.
|
||||
//
|
||||
// While decrypting, it updates the POLYVAL value found at the beginning of
|
||||
// |in_out_calculated_tag_and_scratch| and writes the updated value back before
|
||||
// return. During executation, it may use the whole of this space for other
|
||||
// purposes. In order to decrypt and update the POLYVAL value, it uses the
|
||||
// expanded key from |key| and the table of powers in |htable|.
|
||||
// While decrypting, the whole of |in_out_calculated_tag_and_scratch| may be
|
||||
// used for other purposes. In order to decrypt and update the POLYVAL value, it
|
||||
// uses the expanded key from |key| and the table of powers in |htable|.
|
||||
extern void aes128gcmsiv_dec(const uint8_t *in, uint8_t *out,
|
||||
uint8_t in_out_calculated_tag_and_scratch[16 * 8],
|
||||
const uint8_t htable[16 * 6],
|
||||
@@ -217,6 +220,7 @@ extern void aes256gcmsiv_enc_msg_x8(const uint8_t *in, uint8_t *out,
|
||||
const uint8_t *tag,
|
||||
const struct aead_aes_gcm_siv_asm_ctx *key,
|
||||
size_t in_len);
|
||||
}
|
||||
|
||||
// gcm_siv_asm_polyval evaluates POLYVAL at |auth_key| on the given plaintext
|
||||
// and AD. The result is written to |out_tag|.
|
||||
@@ -228,7 +232,7 @@ static void gcm_siv_asm_polyval(uint8_t out_tag[16], const uint8_t *in,
|
||||
const size_t ad_blocks = ad_len / 16;
|
||||
const size_t in_blocks = in_len / 16;
|
||||
int htable_init = 0;
|
||||
alignas(16) uint8_t htable[16*8];
|
||||
alignas(16) uint8_t htable[16 * 8];
|
||||
|
||||
if (ad_blocks > 8 || in_blocks > 8) {
|
||||
htable_init = 1;
|
||||
@@ -335,8 +339,7 @@ static int aead_aes_gcm_siv_asm_seal_scatter(
|
||||
const uint64_t in_len_64 = in_len;
|
||||
const uint64_t ad_len_64 = ad_len;
|
||||
|
||||
if (in_len_64 > (UINT64_C(1) << 36) ||
|
||||
ad_len_64 >= (UINT64_C(1) << 61)) {
|
||||
if (in_len_64 > (UINT64_C(1) << 36) || ad_len_64 >= (UINT64_C(1) << 61)) {
|
||||
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
|
||||
return 0;
|
||||
}
|
||||
@@ -393,14 +396,10 @@ static int aead_aes_gcm_siv_asm_seal_scatter(
|
||||
return 1;
|
||||
}
|
||||
|
||||
// TODO(martinkr): Add aead_aes_gcm_siv_asm_open_gather. N.B. aes128gcmsiv_dec
|
||||
// expects ciphertext and tag in a contiguous buffer.
|
||||
|
||||
static int aead_aes_gcm_siv_asm_open(const EVP_AEAD_CTX *ctx, uint8_t *out,
|
||||
size_t *out_len, size_t max_out_len,
|
||||
const uint8_t *nonce, size_t nonce_len,
|
||||
const uint8_t *in, size_t in_len,
|
||||
const uint8_t *ad, size_t ad_len) {
|
||||
static int aead_aes_gcm_siv_asm_open_gather(
|
||||
const EVP_AEAD_CTX *ctx, uint8_t *out, const uint8_t *nonce,
|
||||
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *in_tag,
|
||||
size_t in_tag_len, const uint8_t *ad, size_t ad_len) {
|
||||
const uint64_t ad_len_64 = ad_len;
|
||||
if (ad_len_64 >= (UINT64_C(1) << 61)) {
|
||||
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
|
||||
@@ -408,8 +407,8 @@ static int aead_aes_gcm_siv_asm_open(const EVP_AEAD_CTX *ctx, uint8_t *out,
|
||||
}
|
||||
|
||||
const uint64_t in_len_64 = in_len;
|
||||
if (in_len < EVP_AEAD_AES_GCM_SIV_TAG_LEN ||
|
||||
in_len_64 > (UINT64_C(1) << 36) + AES_BLOCK_SIZE) {
|
||||
if (in_len_64 > UINT64_C(1) << 36 ||
|
||||
in_tag_len != EVP_AEAD_AES_GCM_SIV_TAG_LEN) {
|
||||
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
|
||||
return 0;
|
||||
}
|
||||
@@ -420,13 +419,6 @@ static int aead_aes_gcm_siv_asm_open(const EVP_AEAD_CTX *ctx, uint8_t *out,
|
||||
}
|
||||
|
||||
const struct aead_aes_gcm_siv_asm_ctx *gcm_siv_ctx = asm_ctx_from_ctx(ctx);
|
||||
const size_t plaintext_len = in_len - EVP_AEAD_AES_GCM_SIV_TAG_LEN;
|
||||
const uint8_t *const given_tag = in + plaintext_len;
|
||||
|
||||
if (max_out_len < plaintext_len) {
|
||||
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
alignas(16) uint64_t record_auth_key[2];
|
||||
alignas(16) uint64_t record_enc_key[4];
|
||||
@@ -435,9 +427,9 @@ static int aead_aes_gcm_siv_asm_open(const EVP_AEAD_CTX *ctx, uint8_t *out,
|
||||
|
||||
struct aead_aes_gcm_siv_asm_ctx expanded_key;
|
||||
if (gcm_siv_ctx->is_128_bit) {
|
||||
aes128gcmsiv_aes_ks((const uint8_t *) record_enc_key, &expanded_key.key[0]);
|
||||
aes128gcmsiv_aes_ks((const uint8_t *)record_enc_key, &expanded_key.key[0]);
|
||||
} else {
|
||||
aes256gcmsiv_aes_ks((const uint8_t *) record_enc_key, &expanded_key.key[0]);
|
||||
aes256gcmsiv_aes_ks((const uint8_t *)record_enc_key, &expanded_key.key[0]);
|
||||
}
|
||||
// calculated_tag is 16*8 bytes, rather than 16 bytes, because
|
||||
// aes[128|256]gcmsiv_dec uses the extra as scratch space.
|
||||
@@ -459,27 +451,27 @@ static int aead_aes_gcm_siv_asm_open(const EVP_AEAD_CTX *ctx, uint8_t *out,
|
||||
alignas(16) uint8_t htable[16 * 6];
|
||||
aesgcmsiv_htable6_init(htable, (const uint8_t *)record_auth_key);
|
||||
|
||||
// aes[128|256]gcmsiv_dec needs access to the claimed tag. So it's put into
|
||||
// its scratch space.
|
||||
memcpy(calculated_tag + 16, in_tag, EVP_AEAD_AES_GCM_SIV_TAG_LEN);
|
||||
if (gcm_siv_ctx->is_128_bit) {
|
||||
aes128gcmsiv_dec(in, out, calculated_tag, htable, &expanded_key,
|
||||
plaintext_len);
|
||||
aes128gcmsiv_dec(in, out, calculated_tag, htable, &expanded_key, in_len);
|
||||
} else {
|
||||
aes256gcmsiv_dec(in, out, calculated_tag, htable, &expanded_key,
|
||||
plaintext_len);
|
||||
aes256gcmsiv_dec(in, out, calculated_tag, htable, &expanded_key, in_len);
|
||||
}
|
||||
|
||||
if (plaintext_len & 15) {
|
||||
if (in_len & 15) {
|
||||
aead_aes_gcm_siv_asm_crypt_last_block(gcm_siv_ctx->is_128_bit, out, in,
|
||||
plaintext_len, given_tag,
|
||||
&expanded_key);
|
||||
in_len, in_tag, &expanded_key);
|
||||
OPENSSL_memset(scratch, 0, sizeof(scratch));
|
||||
OPENSSL_memcpy(scratch, out + (plaintext_len & ~15), plaintext_len & 15);
|
||||
OPENSSL_memcpy(scratch, out + (in_len & ~15), in_len & 15);
|
||||
aesgcmsiv_polyval_horner(calculated_tag, (const uint8_t *)record_auth_key,
|
||||
scratch, 1);
|
||||
}
|
||||
|
||||
uint8_t length_block[16];
|
||||
CRYPTO_store_u64_le(length_block, ad_len * 8);
|
||||
CRYPTO_store_u64_le(length_block + 8, plaintext_len * 8);
|
||||
CRYPTO_store_u64_le(length_block + 8, in_len * 8);
|
||||
aesgcmsiv_polyval_horner(calculated_tag, (const uint8_t *)record_auth_key,
|
||||
length_block, 1);
|
||||
|
||||
@@ -495,13 +487,12 @@ static int aead_aes_gcm_siv_asm_open(const EVP_AEAD_CTX *ctx, uint8_t *out,
|
||||
aes256gcmsiv_ecb_enc_block(calculated_tag, calculated_tag, &expanded_key);
|
||||
}
|
||||
|
||||
if (CRYPTO_memcmp(calculated_tag, given_tag, EVP_AEAD_AES_GCM_SIV_TAG_LEN) !=
|
||||
if (CRYPTO_memcmp(calculated_tag, in_tag, EVP_AEAD_AES_GCM_SIV_TAG_LEN) !=
|
||||
0) {
|
||||
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*out_len = in_len - EVP_AEAD_AES_GCM_SIV_TAG_LEN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -515,9 +506,9 @@ static const EVP_AEAD aead_aes_128_gcm_siv_asm = {
|
||||
aead_aes_gcm_siv_asm_init,
|
||||
NULL /* init_with_direction */,
|
||||
aead_aes_gcm_siv_asm_cleanup,
|
||||
aead_aes_gcm_siv_asm_open,
|
||||
NULL /* open */,
|
||||
aead_aes_gcm_siv_asm_seal_scatter,
|
||||
NULL /* open_gather */,
|
||||
aead_aes_gcm_siv_asm_open_gather,
|
||||
NULL /* get_iv */,
|
||||
NULL /* tag_len */,
|
||||
};
|
||||
@@ -532,9 +523,9 @@ static const EVP_AEAD aead_aes_256_gcm_siv_asm = {
|
||||
aead_aes_gcm_siv_asm_init,
|
||||
NULL /* init_with_direction */,
|
||||
aead_aes_gcm_siv_asm_cleanup,
|
||||
aead_aes_gcm_siv_asm_open,
|
||||
NULL /* open */,
|
||||
aead_aes_gcm_siv_asm_seal_scatter,
|
||||
NULL /* open_gather */,
|
||||
aead_aes_gcm_siv_asm_open_gather,
|
||||
NULL /* get_iv */,
|
||||
NULL /* tag_len */,
|
||||
};
|
||||
@@ -547,7 +538,7 @@ struct aead_aes_gcm_siv_ctx {
|
||||
AES_KEY ks;
|
||||
} ks;
|
||||
block128_f kgk_block;
|
||||
unsigned is_256:1;
|
||||
unsigned is_256 : 1;
|
||||
};
|
||||
|
||||
static_assert(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
|
||||
@@ -647,8 +638,8 @@ static void gcm_siv_polyval(
|
||||
}
|
||||
|
||||
uint8_t length_block[16];
|
||||
CRYPTO_store_u64_le(length_block, ad_len * 8);
|
||||
CRYPTO_store_u64_le(length_block + 8, in_len * 8);
|
||||
CRYPTO_store_u64_le(length_block, ((uint64_t)ad_len) * 8);
|
||||
CRYPTO_store_u64_le(length_block + 8, ((uint64_t)in_len) * 8);
|
||||
CRYPTO_POLYVAL_update_blocks(&polyval_ctx, length_block,
|
||||
sizeof(length_block));
|
||||
|
||||
@@ -671,10 +662,9 @@ struct gcm_siv_record_keys {
|
||||
|
||||
// gcm_siv_keys calculates the keys for a specific GCM-SIV record with the
|
||||
// given nonce and writes them to |*out_keys|.
|
||||
static void gcm_siv_keys(
|
||||
const struct aead_aes_gcm_siv_ctx *gcm_siv_ctx,
|
||||
struct gcm_siv_record_keys *out_keys,
|
||||
const uint8_t nonce[EVP_AEAD_AES_GCM_SIV_NONCE_LEN]) {
|
||||
static void gcm_siv_keys(const struct aead_aes_gcm_siv_ctx *gcm_siv_ctx,
|
||||
struct gcm_siv_record_keys *out_keys,
|
||||
const uint8_t nonce[EVP_AEAD_AES_GCM_SIV_NONCE_LEN]) {
|
||||
const AES_KEY *const key = &gcm_siv_ctx->ks.ks;
|
||||
uint8_t key_material[(128 /* POLYVAL key */ + 256 /* max AES key */) / 8];
|
||||
const size_t blocks_needed = gcm_siv_ctx->is_256 ? 6 : 4;
|
||||
@@ -715,8 +705,7 @@ static int aead_aes_gcm_siv_seal_scatter(
|
||||
const uint64_t ad_len_64 = ad_len;
|
||||
|
||||
if (in_len + EVP_AEAD_AES_GCM_SIV_TAG_LEN < in_len ||
|
||||
in_len_64 > (UINT64_C(1) << 36) ||
|
||||
ad_len_64 >= (UINT64_C(1) << 61)) {
|
||||
in_len_64 > (UINT64_C(1) << 36) || ad_len_64 >= (UINT64_C(1) << 61)) {
|
||||
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
|
||||
return 0;
|
||||
}
|
||||
@@ -842,12 +831,8 @@ const EVP_AEAD *EVP_aead_aes_256_gcm_siv(void) {
|
||||
|
||||
#else
|
||||
|
||||
const EVP_AEAD *EVP_aead_aes_128_gcm_siv(void) {
|
||||
return &aead_aes_128_gcm_siv;
|
||||
}
|
||||
const EVP_AEAD *EVP_aead_aes_128_gcm_siv(void) { return &aead_aes_128_gcm_siv; }
|
||||
|
||||
const EVP_AEAD *EVP_aead_aes_256_gcm_siv(void) {
|
||||
return &aead_aes_256_gcm_siv;
|
||||
}
|
||||
const EVP_AEAD *EVP_aead_aes_256_gcm_siv(void) { return &aead_aes_256_gcm_siv; }
|
||||
|
||||
#endif // AES_GCM_SIV_ASM
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2014, Google Inc.
|
||||
/* Copyright 2014 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
+76
-95
@@ -58,6 +58,7 @@
|
||||
#include <CCryptoBoringSSL_des.h>
|
||||
#include <CCryptoBoringSSL_nid.h>
|
||||
|
||||
#include "../des/internal.h"
|
||||
#include "../fipsmodule/cipher/internal.h"
|
||||
#include "internal.h"
|
||||
|
||||
@@ -71,35 +72,29 @@ typedef struct {
|
||||
|
||||
static int des_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key,
|
||||
const uint8_t *iv, int enc) {
|
||||
DES_cblock *deskey = (DES_cblock *)key;
|
||||
EVP_DES_KEY *dat = (EVP_DES_KEY *)ctx->cipher_data;
|
||||
|
||||
DES_set_key(deskey, &dat->ks.ks);
|
||||
DES_set_key_ex(key, &dat->ks.ks);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
|
||||
size_t in_len) {
|
||||
EVP_DES_KEY *dat = (EVP_DES_KEY *)ctx->cipher_data;
|
||||
|
||||
DES_ncbc_encrypt(in, out, in_len, &dat->ks.ks, (DES_cblock *)ctx->iv,
|
||||
ctx->encrypt);
|
||||
|
||||
DES_ncbc_encrypt_ex(in, out, in_len, &dat->ks.ks, ctx->iv, ctx->encrypt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const EVP_CIPHER evp_des_cbc = {
|
||||
/* nid = */ NID_des_cbc,
|
||||
/* block_size = */ 8,
|
||||
/* key_len = */ 8,
|
||||
/* iv_len = */ 8,
|
||||
/* ctx_size = */ sizeof(EVP_DES_KEY),
|
||||
/* flags = */ EVP_CIPH_CBC_MODE,
|
||||
/* app_data = */ NULL,
|
||||
/* init = */ des_init_key,
|
||||
/* cipher = */ des_cbc_cipher,
|
||||
/* cleanup = */ NULL,
|
||||
/* ctrl = */ NULL,
|
||||
/*nid=*/NID_des_cbc,
|
||||
/*block_size=*/8,
|
||||
/*key_len=*/8,
|
||||
/*iv_len=*/8,
|
||||
/*ctx_size=*/sizeof(EVP_DES_KEY),
|
||||
/*flags=*/EVP_CIPH_CBC_MODE,
|
||||
/*init=*/des_init_key,
|
||||
/*cipher=*/des_cbc_cipher,
|
||||
/*cleanup=*/nullptr,
|
||||
/*ctrl=*/nullptr,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *EVP_des_cbc(void) { return &evp_des_cbc; }
|
||||
@@ -113,24 +108,22 @@ static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
|
||||
|
||||
EVP_DES_KEY *dat = (EVP_DES_KEY *)ctx->cipher_data;
|
||||
for (size_t i = 0; i <= in_len; i += ctx->cipher->block_size) {
|
||||
DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i),
|
||||
&dat->ks.ks, ctx->encrypt);
|
||||
DES_ecb_encrypt_ex(in + i, out + i, &dat->ks.ks, ctx->encrypt);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const EVP_CIPHER evp_des_ecb = {
|
||||
/* nid = */ NID_des_ecb,
|
||||
/* block_size = */ 8,
|
||||
/* key_len = */ 8,
|
||||
/* iv_len = */ 0,
|
||||
/* ctx_size = */ sizeof(EVP_DES_KEY),
|
||||
/* flags = */ EVP_CIPH_ECB_MODE,
|
||||
/* app_data = */ NULL,
|
||||
/* init = */ des_init_key,
|
||||
/* cipher = */ des_ecb_cipher,
|
||||
/* cleanup = */ NULL,
|
||||
/* ctrl = */ NULL,
|
||||
/*nid=*/NID_des_ecb,
|
||||
/*block_size=*/8,
|
||||
/*key_len=*/8,
|
||||
/*iv_len=*/0,
|
||||
/*ctx_size=*/sizeof(EVP_DES_KEY),
|
||||
/*flags=*/EVP_CIPH_ECB_MODE,
|
||||
/*init=*/des_init_key,
|
||||
/*cipher=*/des_ecb_cipher,
|
||||
/*cleanup=*/nullptr,
|
||||
/*ctrl=*/nullptr,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *EVP_des_ecb(void) { return &evp_des_ecb; }
|
||||
@@ -144,66 +137,57 @@ typedef struct {
|
||||
|
||||
static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key,
|
||||
const uint8_t *iv, int enc) {
|
||||
DES_cblock *deskey = (DES_cblock *)key;
|
||||
DES_EDE_KEY *dat = (DES_EDE_KEY *)ctx->cipher_data;
|
||||
|
||||
DES_set_key(&deskey[0], &dat->ks.ks[0]);
|
||||
DES_set_key(&deskey[1], &dat->ks.ks[1]);
|
||||
DES_set_key(&deskey[2], &dat->ks.ks[2]);
|
||||
|
||||
DES_set_key_ex(key, &dat->ks.ks[0]);
|
||||
DES_set_key_ex(key + 8, &dat->ks.ks[1]);
|
||||
DES_set_key_ex(key + 16, &dat->ks.ks[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int des_ede3_cbc_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out,
|
||||
const uint8_t *in, size_t in_len) {
|
||||
DES_EDE_KEY *dat = (DES_EDE_KEY *)ctx->cipher_data;
|
||||
|
||||
DES_ede3_cbc_encrypt(in, out, in_len, &dat->ks.ks[0], &dat->ks.ks[1],
|
||||
&dat->ks.ks[2], (DES_cblock *)ctx->iv, ctx->encrypt);
|
||||
|
||||
DES_ede3_cbc_encrypt_ex(in, out, in_len, &dat->ks.ks[0], &dat->ks.ks[1],
|
||||
&dat->ks.ks[2], ctx->iv, ctx->encrypt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const EVP_CIPHER evp_des_ede3_cbc = {
|
||||
/* nid = */ NID_des_ede3_cbc,
|
||||
/* block_size = */ 8,
|
||||
/* key_len = */ 24,
|
||||
/* iv_len = */ 8,
|
||||
/* ctx_size = */ sizeof(DES_EDE_KEY),
|
||||
/* flags = */ EVP_CIPH_CBC_MODE,
|
||||
/* app_data = */ NULL,
|
||||
/* init = */ des_ede3_init_key,
|
||||
/* cipher = */ des_ede3_cbc_cipher,
|
||||
/* cleanup = */ NULL,
|
||||
/* ctrl = */ NULL,
|
||||
/*nid=*/NID_des_ede3_cbc,
|
||||
/*block_size=*/8,
|
||||
/*key_len=*/24,
|
||||
/*iv_len=*/8,
|
||||
/*ctx_size=*/sizeof(DES_EDE_KEY),
|
||||
/*flags=*/EVP_CIPH_CBC_MODE,
|
||||
/*init=*/des_ede3_init_key,
|
||||
/*cipher=*/des_ede3_cbc_cipher,
|
||||
/*cleanup=*/nullptr,
|
||||
/*ctrl=*/nullptr,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *EVP_des_ede3_cbc(void) { return &evp_des_ede3_cbc; }
|
||||
|
||||
static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key,
|
||||
const uint8_t *iv, int enc) {
|
||||
DES_cblock *deskey = (DES_cblock *)key;
|
||||
DES_EDE_KEY *dat = (DES_EDE_KEY *)ctx->cipher_data;
|
||||
|
||||
DES_set_key(&deskey[0], &dat->ks.ks[0]);
|
||||
DES_set_key(&deskey[1], &dat->ks.ks[1]);
|
||||
DES_set_key(&deskey[0], &dat->ks.ks[2]);
|
||||
|
||||
// 2-DES is 3-DES with the first key used twice.
|
||||
DES_set_key_ex(key, &dat->ks.ks[0]);
|
||||
DES_set_key_ex(key + 8, &dat->ks.ks[1]);
|
||||
DES_set_key_ex(key, &dat->ks.ks[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const EVP_CIPHER evp_des_ede_cbc = {
|
||||
/* nid = */ NID_des_ede_cbc,
|
||||
/* block_size = */ 8,
|
||||
/* key_len = */ 16,
|
||||
/* iv_len = */ 8,
|
||||
/* ctx_size = */ sizeof(DES_EDE_KEY),
|
||||
/* flags = */ EVP_CIPH_CBC_MODE,
|
||||
/* app_data = */ NULL,
|
||||
/* init = */ des_ede_init_key,
|
||||
/* cipher = */ des_ede3_cbc_cipher,
|
||||
/* cleanup = */ NULL,
|
||||
/* ctrl = */ NULL,
|
||||
/*nid=*/NID_des_ede_cbc,
|
||||
/*block_size=*/8,
|
||||
/*key_len=*/16,
|
||||
/*iv_len=*/8,
|
||||
/*ctx_size=*/sizeof(DES_EDE_KEY),
|
||||
/*flags=*/EVP_CIPH_CBC_MODE,
|
||||
/*init=*/des_ede_init_key,
|
||||
/*cipher=*/des_ede3_cbc_cipher,
|
||||
/*cleanup=*/nullptr,
|
||||
/*ctrl=*/nullptr,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *EVP_des_ede_cbc(void) { return &evp_des_ede_cbc; }
|
||||
@@ -215,43 +199,40 @@ static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out,
|
||||
}
|
||||
in_len -= ctx->cipher->block_size;
|
||||
|
||||
DES_EDE_KEY *dat = (DES_EDE_KEY *) ctx->cipher_data;
|
||||
DES_EDE_KEY *dat = (DES_EDE_KEY *)ctx->cipher_data;
|
||||
for (size_t i = 0; i <= in_len; i += ctx->cipher->block_size) {
|
||||
DES_ecb3_encrypt((DES_cblock *) (in + i), (DES_cblock *) (out + i),
|
||||
&dat->ks.ks[0], &dat->ks.ks[1], &dat->ks.ks[2],
|
||||
ctx->encrypt);
|
||||
DES_ecb3_encrypt_ex(in + i, out + i, &dat->ks.ks[0], &dat->ks.ks[1],
|
||||
&dat->ks.ks[2], ctx->encrypt);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const EVP_CIPHER evp_des_ede = {
|
||||
/* nid = */ NID_des_ede_ecb,
|
||||
/* block_size = */ 8,
|
||||
/* key_len = */ 16,
|
||||
/* iv_len = */ 0,
|
||||
/* ctx_size = */ sizeof(DES_EDE_KEY),
|
||||
/* flags = */ EVP_CIPH_ECB_MODE,
|
||||
/* app_data = */ NULL,
|
||||
/* init = */ des_ede_init_key,
|
||||
/* cipher = */ des_ede_ecb_cipher,
|
||||
/* cleanup = */ NULL,
|
||||
/* ctrl = */ NULL,
|
||||
/*nid=*/NID_des_ede_ecb,
|
||||
/*block_size=*/8,
|
||||
/*key_len=*/16,
|
||||
/*iv_len=*/0,
|
||||
/*ctx_size=*/sizeof(DES_EDE_KEY),
|
||||
/*flags=*/EVP_CIPH_ECB_MODE,
|
||||
/*init=*/des_ede_init_key,
|
||||
/*cipher=*/des_ede_ecb_cipher,
|
||||
/*cleanup=*/nullptr,
|
||||
/*ctrl=*/nullptr,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *EVP_des_ede(void) { return &evp_des_ede; }
|
||||
|
||||
static const EVP_CIPHER evp_des_ede3 = {
|
||||
/* nid = */ NID_des_ede3_ecb,
|
||||
/* block_size = */ 8,
|
||||
/* key_len = */ 24,
|
||||
/* iv_len = */ 0,
|
||||
/* ctx_size = */ sizeof(DES_EDE_KEY),
|
||||
/* flags = */ EVP_CIPH_ECB_MODE,
|
||||
/* app_data = */ NULL,
|
||||
/* init = */ des_ede3_init_key,
|
||||
/* cipher = */ des_ede_ecb_cipher,
|
||||
/* cleanup = */ NULL,
|
||||
/* ctrl = */ NULL,
|
||||
/*nid=*/NID_des_ede3_ecb,
|
||||
/*block_size=*/8,
|
||||
/*key_len=*/24,
|
||||
/*iv_len=*/0,
|
||||
/*ctx_size=*/sizeof(DES_EDE_KEY),
|
||||
/*flags=*/EVP_CIPH_ECB_MODE,
|
||||
/*init=*/des_ede3_init_key,
|
||||
/*cipher=*/des_ede_ecb_cipher,
|
||||
/*cleanup=*/nullptr,
|
||||
/*ctrl=*/nullptr,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *EVP_des_ede3(void) { return &evp_des_ede3; }
|
||||
+12
-5
@@ -69,8 +69,8 @@ static int null_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int null_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out,
|
||||
const uint8_t *in, size_t in_len) {
|
||||
static int null_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
|
||||
size_t in_len) {
|
||||
if (in != out) {
|
||||
OPENSSL_memcpy(out, in, in_len);
|
||||
}
|
||||
@@ -78,9 +78,16 @@ static int null_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out,
|
||||
}
|
||||
|
||||
static const EVP_CIPHER n_cipher = {
|
||||
NID_undef, 1 /* block size */, 0 /* key_len */, 0 /* iv_len */,
|
||||
0 /* ctx_size */, 0 /* flags */, NULL /* app_data */, null_init_key,
|
||||
null_cipher, NULL /* cleanup */, NULL /* ctrl */,
|
||||
/*nid=*/NID_undef,
|
||||
/*block_size=*/1,
|
||||
/*key_len=*/0,
|
||||
/*iv_len=*/0,
|
||||
/*ctx_size=*/0,
|
||||
/*flags=*/0,
|
||||
/*init=*/null_init_key,
|
||||
/*cipher=*/null_cipher,
|
||||
/*cleanup=*/nullptr,
|
||||
/*ctrl=*/nullptr,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *EVP_enc_null(void) { return &n_cipher; }
|
||||
+25
-29
@@ -138,7 +138,9 @@
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
typedef struct rc2_key_st { uint16_t data[64]; } RC2_KEY;
|
||||
typedef struct rc2_key_st {
|
||||
uint16_t data[64];
|
||||
} RC2_KEY;
|
||||
|
||||
static void RC2_encrypt(uint32_t *d, RC2_KEY *key) {
|
||||
int i, n;
|
||||
@@ -427,37 +429,31 @@ static int rc2_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) {
|
||||
}
|
||||
|
||||
static const EVP_CIPHER rc2_40_cbc = {
|
||||
NID_rc2_40_cbc,
|
||||
8 /* block size */,
|
||||
5 /* 40 bit */,
|
||||
8 /* iv len */,
|
||||
sizeof(EVP_RC2_KEY),
|
||||
EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
|
||||
NULL /* app_data */,
|
||||
rc2_init_key,
|
||||
rc2_cbc_cipher,
|
||||
NULL,
|
||||
rc2_ctrl,
|
||||
/*nid=*/NID_rc2_40_cbc,
|
||||
/*block_size=*/8,
|
||||
/*key_len=*/5 /* 40 bit */,
|
||||
/*iv_len=*/8,
|
||||
/*ctx_size=*/sizeof(EVP_RC2_KEY),
|
||||
/*flags=*/EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
|
||||
/*init=*/rc2_init_key,
|
||||
/*cipher=*/rc2_cbc_cipher,
|
||||
/*cleanup=*/nullptr,
|
||||
/*ctrl=*/rc2_ctrl,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *EVP_rc2_40_cbc(void) {
|
||||
return &rc2_40_cbc;
|
||||
}
|
||||
const EVP_CIPHER *EVP_rc2_40_cbc(void) { return &rc2_40_cbc; }
|
||||
|
||||
static const EVP_CIPHER rc2_cbc = {
|
||||
NID_rc2_cbc,
|
||||
8 /* block size */,
|
||||
16 /* 128 bit */,
|
||||
8 /* iv len */,
|
||||
sizeof(EVP_RC2_KEY),
|
||||
EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
|
||||
NULL /* app_data */,
|
||||
rc2_init_key,
|
||||
rc2_cbc_cipher,
|
||||
NULL,
|
||||
rc2_ctrl,
|
||||
/*nid=*/NID_rc2_cbc,
|
||||
/*block_size=*/8,
|
||||
/*key_len=*/16 /* 128 bit */,
|
||||
/*iv_len=*/8,
|
||||
/*ctx_size=*/sizeof(EVP_RC2_KEY),
|
||||
/*flags=*/EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
|
||||
/*init=*/rc2_init_key,
|
||||
/*cipher=*/rc2_cbc_cipher,
|
||||
/*cleanup=*/nullptr,
|
||||
/*ctrl=*/rc2_ctrl,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *EVP_rc2_cbc(void) {
|
||||
return &rc2_cbc;
|
||||
}
|
||||
const EVP_CIPHER *EVP_rc2_cbc(void) { return &rc2_cbc; }
|
||||
+11
-4
@@ -81,9 +81,16 @@ static int rc4_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
|
||||
}
|
||||
|
||||
static const EVP_CIPHER rc4 = {
|
||||
NID_rc4, 1 /* block_size */, 16 /* key_size */,
|
||||
0 /* iv_len */, sizeof(RC4_KEY), EVP_CIPH_VARIABLE_LENGTH,
|
||||
NULL /* app_data */, rc4_init_key, rc4_cipher,
|
||||
NULL /* cleanup */, NULL /* ctrl */, };
|
||||
/*nid=*/NID_rc4,
|
||||
/*block_size=*/1,
|
||||
/*key_len=*/16,
|
||||
/*iv_len=*/0,
|
||||
/*ctx_size=*/sizeof(RC4_KEY),
|
||||
/*flags=*/EVP_CIPH_VARIABLE_LENGTH,
|
||||
/*init=*/rc4_init_key,
|
||||
/*cipher=*/rc4_cipher,
|
||||
/*cleanup=*/nullptr,
|
||||
/*ctrl=*/nullptr,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *EVP_rc4(void) { return &rc4; }
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2014, Google Inc.
|
||||
/* Copyright 2014 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -442,6 +442,7 @@ static int aead_tls_get_iv(const EVP_AEAD_CTX *ctx, const uint8_t **out_iv,
|
||||
const AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)&ctx->state;
|
||||
const size_t iv_len = EVP_CIPHER_CTX_iv_length(&tls_ctx->cipher_ctx);
|
||||
if (iv_len <= 1) {
|
||||
OPENSSL_PUT_ERROR(CIPHER, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -192,22 +192,65 @@ OPENSSL_INLINE int chacha20_poly1305_asm_capable(void) {
|
||||
// Additional input parameters are passed in |aead_data->in|. On exit, it will
|
||||
// write calculated tag value to |aead_data->out.tag|, which the caller must
|
||||
// check.
|
||||
#if defined(OPENSSL_X86_64)
|
||||
extern void chacha20_poly1305_open_nohw(
|
||||
uint8_t *out_plaintext, const uint8_t *ciphertext, size_t plaintext_len,
|
||||
const uint8_t *ad, size_t ad_len, union chacha20_poly1305_open_data *data);
|
||||
extern void chacha20_poly1305_open_avx2(
|
||||
uint8_t *out_plaintext, const uint8_t *ciphertext, size_t plaintext_len,
|
||||
const uint8_t *ad, size_t ad_len, union chacha20_poly1305_open_data *data);
|
||||
OPENSSL_INLINE void chacha20_poly1305_open(uint8_t *out_plaintext,
|
||||
const uint8_t *ciphertext,
|
||||
size_t plaintext_len, const uint8_t *ad,
|
||||
size_t ad_len,
|
||||
union chacha20_poly1305_open_data *data) {
|
||||
if (CRYPTO_is_AVX2_capable() && CRYPTO_is_BMI2_capable()) {
|
||||
chacha20_poly1305_open_avx2(out_plaintext, ciphertext, plaintext_len, ad,
|
||||
ad_len, data);
|
||||
} else {
|
||||
chacha20_poly1305_open_nohw(out_plaintext, ciphertext, plaintext_len, ad,
|
||||
ad_len, data);
|
||||
}
|
||||
}
|
||||
#else
|
||||
extern void chacha20_poly1305_open(uint8_t *out_plaintext,
|
||||
const uint8_t *ciphertext,
|
||||
size_t plaintext_len, const uint8_t *ad,
|
||||
size_t ad_len,
|
||||
union chacha20_poly1305_open_data *data);
|
||||
#endif
|
||||
|
||||
// chacha20_poly1305_open is defined in chacha20_poly1305_*.pl. It encrypts
|
||||
// |plaintext_len| bytes from |plaintext| and writes them to |out_ciphertext|.
|
||||
// Additional input parameters are passed in |aead_data->in|. The calculated tag
|
||||
// value is over the computed ciphertext concatenated with |extra_ciphertext|
|
||||
// and written to |aead_data->out.tag|.
|
||||
#if defined(OPENSSL_X86_64)
|
||||
extern void chacha20_poly1305_seal_nohw(
|
||||
uint8_t *out_ciphertext, const uint8_t *plaintext, size_t plaintext_len,
|
||||
const uint8_t *ad, size_t ad_len, union chacha20_poly1305_seal_data *data);
|
||||
extern void chacha20_poly1305_seal_avx2(
|
||||
uint8_t *out_ciphertext, const uint8_t *plaintext, size_t plaintext_len,
|
||||
const uint8_t *ad, size_t ad_len, union chacha20_poly1305_seal_data *data);
|
||||
OPENSSL_INLINE void chacha20_poly1305_seal(
|
||||
uint8_t *out_ciphertext, const uint8_t *plaintext, size_t plaintext_len,
|
||||
const uint8_t *ad, size_t ad_len, union chacha20_poly1305_seal_data *data) {
|
||||
if (CRYPTO_is_AVX2_capable() && CRYPTO_is_BMI2_capable()) {
|
||||
chacha20_poly1305_seal_avx2(out_ciphertext, plaintext, plaintext_len, ad,
|
||||
ad_len, data);
|
||||
} else {
|
||||
chacha20_poly1305_seal_nohw(out_ciphertext, plaintext, plaintext_len, ad,
|
||||
ad_len, data);
|
||||
}
|
||||
}
|
||||
#else
|
||||
extern void chacha20_poly1305_seal(uint8_t *out_ciphertext,
|
||||
const uint8_t *plaintext,
|
||||
size_t plaintext_len, const uint8_t *ad,
|
||||
size_t ad_len,
|
||||
union chacha20_poly1305_seal_data *data);
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
OPENSSL_INLINE int chacha20_poly1305_asm_capable(void) { return 0; }
|
||||
|
||||
+2
-2
@@ -121,8 +121,8 @@ void EVP_tls_cbc_copy_mac(uint8_t *out, size_t md_size, const uint8_t *in,
|
||||
size_t mac_end = in_len;
|
||||
size_t mac_start = mac_end - md_size;
|
||||
|
||||
assert(orig_len >= in_len);
|
||||
assert(in_len >= md_size);
|
||||
declassify_assert(orig_len >= in_len);
|
||||
declassify_assert(in_len >= md_size);
|
||||
assert(md_size <= EVP_MAX_MD_SIZE);
|
||||
assert(md_size > 0);
|
||||
|
||||
+162
-143
@@ -56,8 +56,9 @@
|
||||
|
||||
#include <CCryptoBoringSSL_conf.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CCryptoBoringSSL_bio.h>
|
||||
#include <CCryptoBoringSSL_buf.h>
|
||||
@@ -65,53 +66,55 @@
|
||||
#include <CCryptoBoringSSL_lhash.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
|
||||
#include "conf_def.h"
|
||||
#include "internal.h"
|
||||
#include "../internal.h"
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
struct conf_section_st {
|
||||
char *name;
|
||||
// values contains non-owning pointers to the values in the section.
|
||||
STACK_OF(CONF_VALUE) *values;
|
||||
};
|
||||
|
||||
static const char kDefaultSectionName[] = "default";
|
||||
|
||||
static uint32_t conf_section_hash(const CONF_SECTION *s) {
|
||||
return OPENSSL_strhash(s->name);
|
||||
}
|
||||
|
||||
static int conf_section_cmp(const CONF_SECTION *a, const CONF_SECTION *b) {
|
||||
return strcmp(a->name, b->name);
|
||||
}
|
||||
|
||||
static uint32_t conf_value_hash(const CONF_VALUE *v) {
|
||||
const uint32_t section_hash = v->section ? OPENSSL_strhash(v->section) : 0;
|
||||
const uint32_t name_hash = v->name ? OPENSSL_strhash(v->name) : 0;
|
||||
const uint32_t section_hash = OPENSSL_strhash(v->section);
|
||||
const uint32_t name_hash = OPENSSL_strhash(v->name);
|
||||
return (section_hash << 2) ^ name_hash;
|
||||
}
|
||||
|
||||
static int conf_value_cmp(const CONF_VALUE *a, const CONF_VALUE *b) {
|
||||
int i;
|
||||
|
||||
if (a->section != b->section) {
|
||||
i = strcmp(a->section, b->section);
|
||||
if (i) {
|
||||
return i;
|
||||
}
|
||||
int cmp = strcmp(a->section, b->section);
|
||||
if (cmp != 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
if (a->name != NULL && b->name != NULL) {
|
||||
return strcmp(a->name, b->name);
|
||||
} else if (a->name == b->name) {
|
||||
return 0;
|
||||
} else {
|
||||
return (a->name == NULL) ? -1 : 1;
|
||||
}
|
||||
return strcmp(a->name, b->name);
|
||||
}
|
||||
|
||||
CONF *NCONF_new(void *method) {
|
||||
CONF *conf;
|
||||
|
||||
if (method != NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
conf = OPENSSL_malloc(sizeof(CONF));
|
||||
CONF *conf = reinterpret_cast<CONF *>(OPENSSL_malloc(sizeof(CONF)));
|
||||
if (conf == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
conf->data = lh_CONF_VALUE_new(conf_value_hash, conf_value_cmp);
|
||||
if (conf->data == NULL) {
|
||||
OPENSSL_free(conf);
|
||||
conf->sections = lh_CONF_SECTION_new(conf_section_hash, conf_section_cmp);
|
||||
conf->values = lh_CONF_VALUE_new(conf_value_hash, conf_value_cmp);
|
||||
if (conf->sections == NULL || conf->values == NULL) {
|
||||
NCONF_free(conf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -119,77 +122,88 @@ CONF *NCONF_new(void *method) {
|
||||
}
|
||||
|
||||
CONF_VALUE *CONF_VALUE_new(void) {
|
||||
CONF_VALUE *v = OPENSSL_malloc(sizeof(CONF_VALUE));
|
||||
if (!v) {
|
||||
return NULL;
|
||||
}
|
||||
OPENSSL_memset(v, 0, sizeof(CONF_VALUE));
|
||||
return v;
|
||||
}
|
||||
|
||||
static void value_free_contents(CONF_VALUE *value) {
|
||||
OPENSSL_free(value->section);
|
||||
if (value->name) {
|
||||
OPENSSL_free(value->name);
|
||||
OPENSSL_free(value->value);
|
||||
} else {
|
||||
// TODO(davidben): When |value->name| is NULL, |CONF_VALUE| is actually an
|
||||
// entirely different structure. This is fragile and confusing. Make a
|
||||
// proper |CONF_SECTION| type that doesn't require this.
|
||||
sk_CONF_VALUE_free((STACK_OF(CONF_VALUE) *)value->value);
|
||||
}
|
||||
return reinterpret_cast<CONF_VALUE *>(OPENSSL_zalloc(sizeof(CONF_VALUE)));
|
||||
}
|
||||
|
||||
static void value_free(CONF_VALUE *value) {
|
||||
if (value != NULL) {
|
||||
value_free_contents(value);
|
||||
OPENSSL_free(value);
|
||||
if (value == NULL) {
|
||||
return;
|
||||
}
|
||||
OPENSSL_free(value->section);
|
||||
OPENSSL_free(value->name);
|
||||
OPENSSL_free(value->value);
|
||||
OPENSSL_free(value);
|
||||
}
|
||||
|
||||
static void section_free(CONF_SECTION *section) {
|
||||
if (section == NULL) {
|
||||
return;
|
||||
}
|
||||
OPENSSL_free(section->name);
|
||||
sk_CONF_VALUE_free(section->values);
|
||||
OPENSSL_free(section);
|
||||
}
|
||||
|
||||
static void value_free_arg(CONF_VALUE *value, void *arg) { value_free(value); }
|
||||
|
||||
static void section_free_arg(CONF_SECTION *section, void *arg) {
|
||||
section_free(section);
|
||||
}
|
||||
|
||||
void NCONF_free(CONF *conf) {
|
||||
if (conf == NULL || conf->data == NULL) {
|
||||
if (conf == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
lh_CONF_VALUE_doall_arg(conf->data, value_free_arg, NULL);
|
||||
lh_CONF_VALUE_free(conf->data);
|
||||
lh_CONF_SECTION_doall_arg(conf->sections, section_free_arg, NULL);
|
||||
lh_CONF_SECTION_free(conf->sections);
|
||||
lh_CONF_VALUE_doall_arg(conf->values, value_free_arg, NULL);
|
||||
lh_CONF_VALUE_free(conf->values);
|
||||
OPENSSL_free(conf);
|
||||
}
|
||||
|
||||
static CONF_VALUE *NCONF_new_section(const CONF *conf, const char *section) {
|
||||
STACK_OF(CONF_VALUE) *sk = NULL;
|
||||
int ok = 0;
|
||||
CONF_VALUE *v = NULL, *old_value;
|
||||
|
||||
sk = sk_CONF_VALUE_new_null();
|
||||
v = CONF_VALUE_new();
|
||||
if (sk == NULL || v == NULL) {
|
||||
goto err;
|
||||
static CONF_SECTION *NCONF_new_section(const CONF *conf, const char *section) {
|
||||
CONF_SECTION *s =
|
||||
reinterpret_cast<CONF_SECTION *>(OPENSSL_malloc(sizeof(CONF_SECTION)));
|
||||
if (!s) {
|
||||
return NULL;
|
||||
}
|
||||
v->section = OPENSSL_strdup(section);
|
||||
if (v->section == NULL) {
|
||||
s->name = OPENSSL_strdup(section);
|
||||
s->values = sk_CONF_VALUE_new_null();
|
||||
if (s->name == NULL || s->values == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
v->name = NULL;
|
||||
v->value = (char *)sk;
|
||||
|
||||
if (!lh_CONF_VALUE_insert(conf->data, &old_value, v)) {
|
||||
CONF_SECTION *old_section;
|
||||
if (!lh_CONF_SECTION_insert(conf->sections, &old_section, s)) {
|
||||
goto err;
|
||||
}
|
||||
value_free(old_value);
|
||||
ok = 1;
|
||||
section_free(old_section);
|
||||
return s;
|
||||
|
||||
err:
|
||||
if (!ok) {
|
||||
sk_CONF_VALUE_free(sk);
|
||||
OPENSSL_free(v);
|
||||
v = NULL;
|
||||
}
|
||||
return v;
|
||||
section_free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int is_comment(char c) { return c == '#'; }
|
||||
|
||||
static int is_quote(char c) { return c == '"' || c == '\'' || c == '`'; }
|
||||
|
||||
static int is_esc(char c) { return c == '\\'; }
|
||||
|
||||
static int is_conf_ws(char c) {
|
||||
// This differs from |OPENSSL_isspace| in that CONF does not accept '\v' and
|
||||
// '\f' as whitespace.
|
||||
return c == ' ' || c == '\t' || c == '\r' || c == '\n';
|
||||
}
|
||||
|
||||
static int is_name_char(char c) {
|
||||
// Alphanumeric characters, and a handful of symbols, may appear in value and
|
||||
// section names without escaping.
|
||||
return OPENSSL_isalnum(c) || c == '_' || c == '!' || c == '.' || c == '%' ||
|
||||
c == '&' || c == '*' || c == '+' || c == ',' || c == '/' || c == ';' ||
|
||||
c == '?' || c == '@' || c == '^' || c == '~' || c == '|' || c == '-';
|
||||
}
|
||||
|
||||
static int str_copy(CONF *conf, char *section, char **pto, char *from) {
|
||||
@@ -208,13 +222,13 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from) {
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (IS_QUOTE(conf, *from)) {
|
||||
if (is_quote(*from)) {
|
||||
q = *from;
|
||||
from++;
|
||||
while (!IS_EOF(conf, *from) && (*from != q)) {
|
||||
if (IS_ESC(conf, *from)) {
|
||||
while (*from != '\0' && *from != q) {
|
||||
if (is_esc(*from)) {
|
||||
from++;
|
||||
if (IS_EOF(conf, *from)) {
|
||||
if (*from == '\0') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -223,10 +237,10 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from) {
|
||||
if (*from == q) {
|
||||
from++;
|
||||
}
|
||||
} else if (IS_ESC(conf, *from)) {
|
||||
} else if (is_esc(*from)) {
|
||||
from++;
|
||||
v = *(from++);
|
||||
if (IS_EOF(conf, v)) {
|
||||
if (v == '\0') {
|
||||
break;
|
||||
} else if (v == 'r') {
|
||||
v = '\r';
|
||||
@@ -238,11 +252,13 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from) {
|
||||
v = '\t';
|
||||
}
|
||||
buf->data[to++] = v;
|
||||
} else if (IS_EOF(conf, *from)) {
|
||||
} else if (*from == '\0') {
|
||||
break;
|
||||
} else if (*from == '$') {
|
||||
// Historically, $foo would expand to a previously-parsed value. This
|
||||
// feature has been removed as it was unused and is a DoS vector.
|
||||
// feature has been removed as it was unused and is a DoS vector. If
|
||||
// trying to embed '$' in a line, either escape it or wrap the value in
|
||||
// quotes.
|
||||
OPENSSL_PUT_ERROR(CONF, CONF_R_VARIABLE_EXPANSION_NOT_SUPPORTED);
|
||||
goto err;
|
||||
} else {
|
||||
@@ -261,92 +277,99 @@ err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static CONF_VALUE *get_section(const CONF *conf, const char *section) {
|
||||
CONF_VALUE template;
|
||||
|
||||
OPENSSL_memset(&template, 0, sizeof(template));
|
||||
template.section = (char *) section;
|
||||
return lh_CONF_VALUE_retrieve(conf->data, &template);
|
||||
static CONF_SECTION *get_section(const CONF *conf, const char *section) {
|
||||
CONF_SECTION templ;
|
||||
OPENSSL_memset(&templ, 0, sizeof(templ));
|
||||
templ.name = (char *)section;
|
||||
return lh_CONF_SECTION_retrieve(conf->sections, &templ);
|
||||
}
|
||||
|
||||
const STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,
|
||||
const char *section) {
|
||||
const CONF_VALUE *section_value = get_section(conf, section);
|
||||
if (section_value == NULL) {
|
||||
const CONF_SECTION *section_obj = get_section(conf, section);
|
||||
if (section_obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return (STACK_OF(CONF_VALUE)*) section_value->value;
|
||||
return section_obj->values;
|
||||
}
|
||||
|
||||
const char *NCONF_get_string(const CONF *conf, const char *section,
|
||||
const char *name) {
|
||||
CONF_VALUE template, *value;
|
||||
CONF_VALUE templ, *value;
|
||||
|
||||
if (section == NULL) {
|
||||
section = kDefaultSectionName;
|
||||
}
|
||||
|
||||
OPENSSL_memset(&template, 0, sizeof(template));
|
||||
template.section = (char *) section;
|
||||
template.name = (char *) name;
|
||||
value = lh_CONF_VALUE_retrieve(conf->data, &template);
|
||||
OPENSSL_memset(&templ, 0, sizeof(templ));
|
||||
templ.section = (char *)section;
|
||||
templ.name = (char *)name;
|
||||
value = lh_CONF_VALUE_retrieve(conf->values, &templ);
|
||||
if (value == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return value->value;
|
||||
}
|
||||
|
||||
static int add_string(const CONF *conf, CONF_VALUE *section,
|
||||
static int add_string(const CONF *conf, CONF_SECTION *section,
|
||||
CONF_VALUE *value) {
|
||||
STACK_OF(CONF_VALUE) *section_stack = (STACK_OF(CONF_VALUE)*) section->value;
|
||||
CONF_VALUE *old_value;
|
||||
|
||||
value->section = OPENSSL_strdup(section->section);
|
||||
if (!sk_CONF_VALUE_push(section_stack, value)) {
|
||||
value->section = OPENSSL_strdup(section->name);
|
||||
if (value->section == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!lh_CONF_VALUE_insert(conf->data, &old_value, value)) {
|
||||
if (!sk_CONF_VALUE_push(section->values, value)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
CONF_VALUE *old_value;
|
||||
if (!lh_CONF_VALUE_insert(conf->values, &old_value, value)) {
|
||||
// Remove |value| from |section->values|, so we do not leave a dangling
|
||||
// pointer.
|
||||
sk_CONF_VALUE_pop(section->values);
|
||||
return 0;
|
||||
}
|
||||
if (old_value != NULL) {
|
||||
(void)sk_CONF_VALUE_delete_ptr(section_stack, old_value);
|
||||
(void)sk_CONF_VALUE_delete_ptr(section->values, old_value);
|
||||
value_free(old_value);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static char *eat_ws(CONF *conf, char *p) {
|
||||
while (IS_WS(conf, *p) && !IS_EOF(conf, *p)) {
|
||||
static char *eat_ws(char *p) {
|
||||
while (*p != '\0' && is_conf_ws(*p)) {
|
||||
p++;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
#define scan_esc(conf, p) (((IS_EOF((conf), (p)[1])) ? ((p) + 1) : ((p) + 2)))
|
||||
static char *scan_esc(char *p) {
|
||||
assert(p[0] == '\\');
|
||||
return p[1] == '\0' ? p + 1 : p + 2;
|
||||
}
|
||||
|
||||
static char *eat_alpha_numeric(CONF *conf, char *p) {
|
||||
static char *eat_name(char *p) {
|
||||
for (;;) {
|
||||
if (IS_ESC(conf, *p)) {
|
||||
p = scan_esc(conf, p);
|
||||
if (is_esc(*p)) {
|
||||
p = scan_esc(p);
|
||||
continue;
|
||||
}
|
||||
if (!IS_ALPHA_NUMERIC_PUNCT(conf, *p)) {
|
||||
if (!is_name_char(*p)) {
|
||||
return p;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
static char *scan_quote(CONF *conf, char *p) {
|
||||
static char *scan_quote(char *p) {
|
||||
int q = *p;
|
||||
|
||||
p++;
|
||||
while (!IS_EOF(conf, *p) && *p != q) {
|
||||
if (IS_ESC(conf, *p)) {
|
||||
while (*p != '\0' && *p != q) {
|
||||
if (is_esc(*p)) {
|
||||
p++;
|
||||
if (IS_EOF(conf, *p)) {
|
||||
if (*p == '\0') {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
@@ -358,28 +381,28 @@ static char *scan_quote(CONF *conf, char *p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
static void clear_comments(CONF *conf, char *p) {
|
||||
static void clear_comments(char *p) {
|
||||
for (;;) {
|
||||
if (!IS_WS(conf, *p)) {
|
||||
if (!is_conf_ws(*p)) {
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (IS_COMMENT(conf, *p)) {
|
||||
if (is_comment(*p)) {
|
||||
*p = '\0';
|
||||
return;
|
||||
}
|
||||
if (IS_QUOTE(conf, *p)) {
|
||||
p = scan_quote(conf, p);
|
||||
if (is_quote(*p)) {
|
||||
p = scan_quote(p);
|
||||
continue;
|
||||
}
|
||||
if (IS_ESC(conf, *p)) {
|
||||
p = scan_esc(conf, p);
|
||||
if (is_esc(*p)) {
|
||||
p = scan_esc(p);
|
||||
continue;
|
||||
}
|
||||
if (IS_EOF(conf, *p)) {
|
||||
if (*p == '\0') {
|
||||
return;
|
||||
} else {
|
||||
p++;
|
||||
@@ -395,8 +418,8 @@ int NCONF_load_bio(CONF *conf, BIO *in, long *out_error_line) {
|
||||
int again;
|
||||
long eline = 0;
|
||||
char btmp[DECIMAL_SIZE(eline) + 1];
|
||||
CONF_VALUE *v = NULL, *tv;
|
||||
CONF_VALUE *sv = NULL;
|
||||
CONF_VALUE *v = NULL;
|
||||
CONF_SECTION *sv = NULL;
|
||||
char *section = NULL, *buf;
|
||||
char *start, *psection, *pname;
|
||||
|
||||
@@ -459,7 +482,7 @@ int NCONF_load_bio(CONF *conf, BIO *in, long *out_error_line) {
|
||||
// If we have bytes and the last char '\\' and
|
||||
// second last char is not '\\'
|
||||
p = &(buff->data[bufnum - 1]);
|
||||
if (IS_ESC(conf, p[0]) && ((bufnum <= 1) || !IS_ESC(conf, p[-1]))) {
|
||||
if (is_esc(p[0]) && ((bufnum <= 1) || !is_esc(p[-1]))) {
|
||||
bufnum--;
|
||||
again = 1;
|
||||
}
|
||||
@@ -470,20 +493,20 @@ int NCONF_load_bio(CONF *conf, BIO *in, long *out_error_line) {
|
||||
bufnum = 0;
|
||||
buf = buff->data;
|
||||
|
||||
clear_comments(conf, buf);
|
||||
s = eat_ws(conf, buf);
|
||||
if (IS_EOF(conf, *s)) {
|
||||
clear_comments(buf);
|
||||
s = eat_ws(buf);
|
||||
if (*s == '\0') {
|
||||
continue; // blank line
|
||||
}
|
||||
if (*s == '[') {
|
||||
char *ss;
|
||||
|
||||
s++;
|
||||
start = eat_ws(conf, s);
|
||||
start = eat_ws(s);
|
||||
ss = start;
|
||||
again:
|
||||
end = eat_alpha_numeric(conf, ss);
|
||||
p = eat_ws(conf, end);
|
||||
end = eat_name(ss);
|
||||
p = eat_ws(end);
|
||||
if (*p != ']') {
|
||||
if (*p != '\0' && ss != p) {
|
||||
ss = p;
|
||||
@@ -507,27 +530,27 @@ int NCONF_load_bio(CONF *conf, BIO *in, long *out_error_line) {
|
||||
} else {
|
||||
pname = s;
|
||||
psection = NULL;
|
||||
end = eat_alpha_numeric(conf, s);
|
||||
end = eat_name(s);
|
||||
if ((end[0] == ':') && (end[1] == ':')) {
|
||||
*end = '\0';
|
||||
end += 2;
|
||||
psection = pname;
|
||||
pname = end;
|
||||
end = eat_alpha_numeric(conf, end);
|
||||
end = eat_name(end);
|
||||
}
|
||||
p = eat_ws(conf, end);
|
||||
p = eat_ws(end);
|
||||
if (*p != '=') {
|
||||
OPENSSL_PUT_ERROR(CONF, CONF_R_MISSING_EQUAL_SIGN);
|
||||
goto err;
|
||||
}
|
||||
*end = '\0';
|
||||
p++;
|
||||
start = eat_ws(conf, p);
|
||||
while (!IS_EOF(conf, *p)) {
|
||||
start = eat_ws(p);
|
||||
while (*p != '\0') {
|
||||
p++;
|
||||
}
|
||||
p--;
|
||||
while ((p != start) && (IS_WS(conf, *p))) {
|
||||
while (p != start && is_conf_ws(*p)) {
|
||||
p--;
|
||||
}
|
||||
p++;
|
||||
@@ -547,6 +570,7 @@ int NCONF_load_bio(CONF *conf, BIO *in, long *out_error_line) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
CONF_SECTION *tv;
|
||||
if (strcmp(psection, section) != 0) {
|
||||
if ((tv = get_section(conf, psection)) == NULL) {
|
||||
tv = NCONF_new_section(conf, psection);
|
||||
@@ -576,12 +600,7 @@ err:
|
||||
}
|
||||
snprintf(btmp, sizeof btmp, "%ld", eline);
|
||||
ERR_add_error_data(2, "line ", btmp);
|
||||
|
||||
if (v != NULL) {
|
||||
OPENSSL_free(v->name);
|
||||
OPENSSL_free(v->value);
|
||||
OPENSSL_free(v);
|
||||
}
|
||||
value_free(v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
// This file was historically generated by keysets.pl in OpenSSL.
|
||||
//
|
||||
// TODO(davidben): Replace it with something more readable.
|
||||
|
||||
#define CONF_NUMBER 1
|
||||
#define CONF_UPPER 2
|
||||
#define CONF_LOWER 4
|
||||
#define CONF_UNDER 256
|
||||
#define CONF_PUNCTUATION 512
|
||||
#define CONF_WS 16
|
||||
#define CONF_ESC 32
|
||||
#define CONF_QUOTE 64
|
||||
#define CONF_COMMENT 128
|
||||
#define CONF_EOF 8
|
||||
#define CONF_HIGHBIT 4096
|
||||
#define CONF_ALPHA (CONF_UPPER|CONF_LOWER)
|
||||
#define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
|
||||
#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \
|
||||
CONF_PUNCTUATION)
|
||||
|
||||
#define KEYTYPES(c) CONF_type_default
|
||||
#define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT)
|
||||
#define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF)
|
||||
#define IS_ESC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ESC)
|
||||
#define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_NUMBER)
|
||||
#define IS_WS(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_WS)
|
||||
#define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC)
|
||||
#define IS_ALPHA_NUMERIC_PUNCT(c,a) \
|
||||
(KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
|
||||
#define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_QUOTE)
|
||||
|
||||
static const unsigned short CONF_type_default[256]={
|
||||
0x0008,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
|
||||
0x0000,0x0010,0x0010,0x0000,0x0000,0x0010,0x0000,0x0000,
|
||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
|
||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
|
||||
0x0010,0x0200,0x0040,0x0080,0x0000,0x0200,0x0200,0x0040,
|
||||
0x0000,0x0000,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,
|
||||
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
|
||||
0x0001,0x0001,0x0000,0x0200,0x0000,0x0000,0x0000,0x0200,
|
||||
0x0200,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,
|
||||
0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,
|
||||
0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,
|
||||
0x0002,0x0002,0x0002,0x0000,0x0020,0x0000,0x0200,0x0100,
|
||||
0x0040,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
|
||||
0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
|
||||
0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
|
||||
0x0004,0x0004,0x0004,0x0000,0x0200,0x0000,0x0200,0x0000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2015, Google Inc.
|
||||
/* Copyright 2015 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -24,10 +24,14 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct conf_section_st CONF_SECTION;
|
||||
|
||||
DEFINE_LHASH_OF(CONF_SECTION)
|
||||
DEFINE_LHASH_OF(CONF_VALUE)
|
||||
|
||||
struct conf_st {
|
||||
LHASH_OF(CONF_VALUE) *data;
|
||||
LHASH_OF(CONF_VALUE) *values;
|
||||
LHASH_OF(CONF_SECTION) *sections;
|
||||
};
|
||||
|
||||
// CONF_VALUE_new returns a freshly allocated and zeroed |CONF_VALUE|.
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2021, Google Inc.
|
||||
/* Copyright 2021 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#if defined(OPENSSL_AARCH64) && defined(OPENSSL_APPLE) && \
|
||||
!defined(OPENSSL_STATIC_ARMCAP)
|
||||
!defined(OPENSSL_STATIC_ARMCAP) && !defined(OPENSSL_NO_ASM)
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2018, Google Inc.
|
||||
/* Copyright 2018 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#if defined(OPENSSL_AARCH64) && defined(OPENSSL_FUCHSIA) && \
|
||||
!defined(OPENSSL_STATIC_ARMCAP)
|
||||
!defined(OPENSSL_STATIC_ARMCAP) && !defined(OPENSSL_NO_ASM)
|
||||
|
||||
#include <zircon/features.h>
|
||||
#include <zircon/syscalls.h>
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2016, Google Inc.
|
||||
/* Copyright 2016 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#if defined(OPENSSL_AARCH64) && defined(OPENSSL_LINUX) && \
|
||||
!defined(OPENSSL_STATIC_ARMCAP)
|
||||
!defined(OPENSSL_STATIC_ARMCAP) && !defined(OPENSSL_NO_ASM)
|
||||
|
||||
#include <sys/auxv.h>
|
||||
|
||||
+4
-4
@@ -15,11 +15,11 @@
|
||||
#include <CCryptoBoringSSL_cpu.h>
|
||||
|
||||
#if defined(OPENSSL_AARCH64) && defined(OPENSSL_OPENBSD) && \
|
||||
!defined(OPENSSL_STATIC_ARMCAP)
|
||||
!defined(OPENSSL_STATIC_ARMCAP) && !defined(OPENSSL_NO_ASM)
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/armreg.h>
|
||||
#include <machine/cpu.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <CCryptoBoringSSL_arm_arch.h>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
|
||||
void OPENSSL_cpuid_setup(void) {
|
||||
int isar0_mib[] = { CTL_MACHDEP, CPU_ID_AA64ISAR0 };
|
||||
int isar0_mib[] = {CTL_MACHDEP, CPU_ID_AA64ISAR0};
|
||||
uint64_t cpu_id = 0;
|
||||
size_t len = sizeof(cpu_id);
|
||||
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2023, Google Inc.
|
||||
/* Copyright 2023 The BoringSSL Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -18,7 +18,8 @@
|
||||
// expects userspace to simply read them. It traps the reads and fills in CPU
|
||||
// capabilities.
|
||||
#if defined(OPENSSL_AARCH64) && !defined(OPENSSL_STATIC_ARMCAP) && \
|
||||
(defined(ANDROID_BAREMETAL) || defined(OPENSSL_FREEBSD))
|
||||
(defined(ANDROID_BAREMETAL) || defined(OPENSSL_FREEBSD)) && \
|
||||
!defined(OPENSSL_NO_ASM)
|
||||
|
||||
#include <CCryptoBoringSSL_arm_arch.h>
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2018, Google Inc.
|
||||
/* Copyright 2018 The BoringSSL Authors
|
||||
* Copyright (c) 2020, Arm Ltd.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#if defined(OPENSSL_AARCH64) && defined(OPENSSL_WINDOWS) && \
|
||||
!defined(OPENSSL_STATIC_ARMCAP)
|
||||
!defined(OPENSSL_STATIC_ARMCAP) && !defined(OPENSSL_NO_ASM)
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/* Copyright (c) 2014, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#if (defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)) && \
|
||||
!defined(OPENSSL_STATIC_ARMCAP)
|
||||
|
||||
#include <CCryptoBoringSSL_arm_arch.h>
|
||||
|
||||
|
||||
int CRYPTO_is_NEON_capable_at_runtime(void) {
|
||||
return (OPENSSL_armcap_P & ARMV7_NEON) != 0;
|
||||
}
|
||||
|
||||
int CRYPTO_is_ARMv8_AES_capable_at_runtime(void) {
|
||||
return (OPENSSL_armcap_P & ARMV8_AES) != 0;
|
||||
}
|
||||
|
||||
int CRYPTO_is_ARMv8_PMULL_capable_at_runtime(void) {
|
||||
return (OPENSSL_armcap_P & ARMV8_PMULL) != 0;
|
||||
}
|
||||
|
||||
#endif /* (defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)) &&
|
||||
!defined(OPENSSL_STATIC_ARMCAP) */
|
||||
Loaded 100 of 869 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user