Skip to content

Commit 6b0a65e

Browse files
authored
Pre commit hook trailing whitespace (#283)
* chore: Add pre-commit hook to disallow trailing whitespace * Remove trailing whitespace All changes in this commit come from running the tailing-whitespace pre-commit hook.
1 parent c17a565 commit 6b0a65e

32 files changed

+105
-100
lines changed

.pre-commit-config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.2.3 # Use the ref you want to point at
4+
hooks:
5+
- id: trailing-whitespace

CODE_OF_CONDUCT.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
## Code of Conduct
2-
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3-
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
2+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
44
[email protected] with any additional questions or comments.

CONTRIBUTING.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Contributing Guidelines
22

3-
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
3+
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
44
documentation, we greatly value feedback and contributions from our community.
55

6-
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
6+
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
77
information to effectively respond to your bug report or contribution.
88

99

1010
## Reporting Bugs/Feature Requests
1111

1212
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
1313

14-
When filing an issue, please check [existing open](https://github.com/awslabs/aws-encryption-sdk-dafny/issues), or [recently closed](https://github.com/awslabs/aws-encryption-sdk-dafny/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
14+
When filing an issue, please check [existing open](https://github.com/awslabs/aws-encryption-sdk-dafny/issues), or [recently closed](https://github.com/awslabs/aws-encryption-sdk-dafny/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
1515
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
1616

1717
* A reproducible test case or series of steps
@@ -41,17 +41,17 @@ To send us a pull request, please:
4141
the resulting commit title and message must adhere to conventional commits.
4242
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
4343

44-
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
44+
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
4545
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
4646

4747

4848
## Finding contributions to work on
49-
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/awslabs/aws-encryption-sdk-dafny/labels/help%20wanted) issues is a great place to start.
49+
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/awslabs/aws-encryption-sdk-dafny/labels/help%20wanted) issues is a great place to start.
5050

5151

5252
## Code of Conduct
53-
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
54-
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
53+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
54+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
5555
[email protected] with any additional questions or comments.
5656

5757

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM ubuntu:18.04
2-
2+
33
USER root
44

55
ENV DEBIAN_FRONTEND=noninteractive

NOTICE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
AWS Encryption SDK Dafny
2-
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.

lib/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ignore all files in this dir...
22
*
3-
3+
44
# ... except for this one.
55
!.gitignore

src/AWSEncryptionSDK.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<DafnySource Include="Util/UTF8.dfy" />
4747
<DafnySource Include="Util/Sets.dfy" />
4848
</ItemGroup>
49-
49+
5050
<ItemGroup>
5151
<PackageReference Include="dafny.msbuild" Version="1.0.0" />
5252
<PackageReference Include="AWSSDK.Core" Version="3.3.104.1" />

src/Crypto/HKDF/HKDF.dfy

+10-10
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ module HKDF {
3737
}
3838

3939
// T is relational since the external hashMethod hmac.GetKey() ensures that the input and output of the hash method are in the relation hmac.HashSignature
40-
// T depends on Ti and Ti depends on hmac.HashSignature
40+
// T depends on Ti and Ti depends on hmac.HashSignature
4141
predicate T(hmac: HMac, info: seq<uint8>, n: nat, res: seq<uint8>)
42-
requires 0 <= n < 256
42+
requires 0 <= n < 256
4343
decreases n
44-
{
45-
if n == 0 then
44+
{
45+
if n == 0 then
4646
[] == res
47-
else
48-
exists prev1, prev2 :: T(hmac, info, n-1, prev1) && Ti(hmac, info, n, prev2) && prev1 + prev2 == res
47+
else
48+
exists prev1, prev2 :: T(hmac, info, n-1, prev1) && Ti(hmac, info, n, prev2) && prev1 + prev2 == res
4949
}
5050

5151
predicate Ti(hmac: HMac, info: seq<uint8>, n: nat, res: seq<uint8>)
5252
requires 0 <= n < 256
5353
decreases n, 1
5454
{
55-
if n == 0 then
55+
if n == 0 then
5656
res == []
5757
else
5858
exists prev :: PreTi(hmac, info, n, prev) && hmac.HashSignature(prev, res)
@@ -111,12 +111,12 @@ module HKDF {
111111
hmac.Update(t_prev);
112112
hmac.Update(info);
113113
hmac.Update([i as uint8]);
114-
assert hmac.GetInputSoFar() == t_prev + info + [i as uint8];
114+
assert hmac.GetInputSoFar() == t_prev + info + [i as uint8];
115115

116116
// Add additional verification for T(n): github.com/awslabs/aws-encryption-sdk-dafny/issues/177
117-
t_prev := hmac.GetResult();
117+
t_prev := hmac.GetResult();
118118
// t_n == T(i - 1)
119-
assert T(hmac, info, i - 1, t_n);
119+
assert T(hmac, info, i - 1, t_n);
120120
assert Ti(hmac, info, i, t_prev) ;
121121

122122
t_n := t_n + t_prev;

src/KMS/KMSUtils.dfy

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module {:extern "KMSUtils"} KMSUtils {
3333
var components := Split(cmk, ':');
3434
UTF8.IsASCIIString(cmk) && 0 < |cmk| <= 2048 && |components| == 6 && components[0] == "arn" && components[2] == "kms" && Split(components[5], '/')[0] == "alias"
3535
}
36-
36+
3737
type GrantToken = s: string | 0 < |s| <= 8192 witness "witness"
3838

3939
datatype ResponseMetadata = ResponseMetadata(metadata: map<string, string>, requestID: string)

src/SDK/EncryptionContext.dfy

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ module {:extern "EncryptionContext"} EncryptionContext {
191191
} else if |encryptionContext| >= UINT16_LIMIT {
192192
return false;
193193
}
194-
194+
195195
// Iterating through a map isn't feasbile in dafny for large maps, so instead
196196
// convert the map to a sequence of key pairs and iterate through the sequence
197197
var keys: seq<UTF8.ValidUTF8Bytes> := Sets.ComputeSetToOrderedSequence<uint8>(encryptionContext.Keys, UInt.UInt8Less);

src/SDK/Keyring/Defs.dfy

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module {:extern "KeyringDefs"} KeyringDefs {
2020
ensures Valid()
2121
ensures res.Success? ==>
2222
&& materials.encryptionContext == res.value.encryptionContext
23-
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
23+
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
2424
&& (materials.plaintextDataKey.Some? ==> res.value.plaintextDataKey == materials.plaintextDataKey)
2525
&& materials.keyringTrace <= res.value.keyringTrace
2626
&& materials.encryptedDataKeys <= res.value.encryptedDataKeys

src/SDK/Keyring/KMSKeyring.dfy

+6-6
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ module {:extern "KMSKeyringDef"} KMSKeyringDef {
6464
requires |materials.encryptedDataKeys| == 0
6565
requires !isDiscovery
6666
ensures Valid()
67-
ensures res.Success? ==>
67+
ensures res.Success? ==>
6868
&& materials.encryptionContext == res.value.encryptionContext
69-
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
69+
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
7070
&& res.value.plaintextDataKey.Some?
7171
&& materials.keyringTrace <= res.value.keyringTrace
7272
&& materials.encryptedDataKeys <= res.value.encryptedDataKeys
@@ -106,9 +106,9 @@ module {:extern "KMSKeyringDef"} KMSKeyringDef {
106106
method OnEncrypt(materials: Mat.ValidEncryptionMaterials) returns (res: Result<Mat.ValidEncryptionMaterials>)
107107
requires Valid()
108108
ensures Valid()
109-
ensures res.Success? ==>
109+
ensures res.Success? ==>
110110
&& materials.encryptionContext == res.value.encryptionContext
111-
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
111+
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
112112
&& (materials.plaintextDataKey.Some? ==> res.value.plaintextDataKey == materials.plaintextDataKey)
113113
&& materials.keyringTrace <= res.value.keyringTrace
114114
&& materials.encryptedDataKeys <= res.value.encryptedDataKeys
@@ -128,7 +128,7 @@ module {:extern "KMSKeyringDef"} KMSKeyringDef {
128128
resultMaterials :- Generate(materials);
129129
assert resultMaterials.plaintextDataKey.Some?;
130130
} else {
131-
resultMaterials := materials;
131+
resultMaterials := materials;
132132
encryptCMKs := encryptCMKs + [generator.get];
133133
}
134134
} else {
@@ -138,7 +138,7 @@ module {:extern "KMSKeyringDef"} KMSKeyringDef {
138138
assert materials.plaintextDataKey.Some? ==> resultMaterials.plaintextDataKey == materials.plaintextDataKey;
139139

140140
var i := 0;
141-
while i < |encryptCMKs|
141+
while i < |encryptCMKs|
142142
invariant resultMaterials.plaintextDataKey.Some?
143143
invariant materials.encryptionContext == resultMaterials.encryptionContext
144144
invariant materials.algorithmSuiteID == resultMaterials.algorithmSuiteID

src/SDK/Keyring/MultiKeyring.dfy

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ module {:extern "MultiKeyringDef"} MultiKeyringDef {
4646
method OnEncrypt(materials: Materials.ValidEncryptionMaterials) returns (res: Result<Materials.ValidEncryptionMaterials>)
4747
requires Valid()
4848
ensures Valid()
49-
ensures res.Success? ==>
49+
ensures res.Success? ==>
5050
&& materials.encryptionContext == res.value.encryptionContext
51-
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
51+
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
5252
&& (materials.plaintextDataKey.Some? ==> res.value.plaintextDataKey == materials.plaintextDataKey)
5353
&& materials.keyringTrace <= res.value.keyringTrace
5454
&& materials.encryptedDataKeys <= res.value.encryptedDataKeys
@@ -74,7 +74,7 @@ module {:extern "MultiKeyringDef"} MultiKeyringDef {
7474
invariant materials.keyringTrace <= resultMaterials.keyringTrace
7575
invariant materials.encryptedDataKeys <= resultMaterials.encryptedDataKeys
7676
invariant materials.signingKey == resultMaterials.signingKey
77-
decreases |children| - i
77+
decreases |children| - i
7878
{
7979
resultMaterials :- children[i].OnEncrypt(resultMaterials);
8080
i := i + 1;
@@ -108,9 +108,9 @@ module {:extern "MultiKeyringDef"} MultiKeyringDef {
108108
}
109109
var i := 0;
110110
while i < |children|
111-
invariant res.Success? ==>
111+
invariant res.Success? ==>
112112
&& materials.encryptionContext == res.value.encryptionContext
113-
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
113+
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
114114
&& (materials.plaintextDataKey.Some? ==> res.value.plaintextDataKey == materials.plaintextDataKey)
115115
&& materials.keyringTrace <= res.value.keyringTrace
116116
&& materials.verificationKey == res.value.verificationKey

src/SDK/Keyring/RawAESKeyring.dfy

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ module {:extern "RawAESKeyringDef"} RawAESKeyringDef {
101101
method OnEncrypt(materials: Mat.ValidEncryptionMaterials) returns (res: Result<Mat.ValidEncryptionMaterials>)
102102
// Keyring Trait conditions
103103
requires Valid()
104-
ensures res.Success? ==>
104+
ensures res.Success? ==>
105105
&& materials.encryptionContext == res.value.encryptionContext
106-
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
106+
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
107107
&& (materials.plaintextDataKey.Some? ==> res.value.plaintextDataKey == materials.plaintextDataKey)
108108
&& materials.keyringTrace <= res.value.keyringTrace
109109
&& materials.encryptedDataKeys <= res.value.encryptedDataKeys
@@ -197,7 +197,7 @@ module {:extern "RawAESKeyringDef"} RawAESKeyringDef {
197197
&& AESEncryption.PlaintextDecryptedWithAAD(res.value.plaintextDataKey.get, EncryptionContext.MapToSeq(materials.encryptionContext))
198198

199199
// KeyringTrace generated as expected
200-
ensures res.Success? && materials.plaintextDataKey.None? && res.value.plaintextDataKey.Some? ==>
200+
ensures res.Success? && materials.plaintextDataKey.None? && res.value.plaintextDataKey.Some? ==>
201201
|res.value.keyringTrace| == |materials.keyringTrace| + 1 && res.value.keyringTrace[|materials.keyringTrace|] == DecryptTraceEntry()
202202

203203
// If attempts to decrypt an EDK and the input EC cannot be serialized, return a Failure
@@ -221,7 +221,7 @@ module {:extern "RawAESKeyringDef"} RawAESKeyringDef {
221221
var _ :- Serialize.SerializeKVPairs(wr, materials.encryptionContext);
222222
var aad := wr.GetDataWritten();
223223
assert aad == EncryptionContext.MapToSeq(materials.encryptionContext);
224-
224+
225225
var iv := GetIvFromProvInfo(edks[i].providerInfo);
226226
var encryptionOutput := DeserializeEDKCiphertext(edks[i].ciphertext, wrappingAlgorithm.tagLen as nat);
227227
var ptKey :- AESEncryption.AESDecrypt(wrappingAlgorithm, wrappingKey, encryptionOutput.cipherText, encryptionOutput.authTag, iv, aad);

src/SDK/Keyring/RawRSAKeyring.dfy

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ module {:extern "RawRSAKeyringDef"} RawRSAKeyringDef {
7474
requires Valid()
7575
// NOTE: encryptionContext is intentionally unused
7676
ensures publicKey.None? ==> res.Failure?
77-
ensures res.Success? ==>
77+
ensures res.Success? ==>
7878
&& materials.encryptionContext == res.value.encryptionContext
79-
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
79+
&& materials.algorithmSuiteID == res.value.algorithmSuiteID
8080
&& (materials.plaintextDataKey.Some? ==> res.value.plaintextDataKey == materials.plaintextDataKey)
8181
&& materials.keyringTrace <= res.value.keyringTrace
8282
&& materials.encryptedDataKeys <= res.value.encryptedDataKeys

src/SDK/Materials.dfy

+6-6
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ module {:extern "Materials"} Materials {
9797

9898
static function method WithoutDataKeys(encryptionContext: EncryptionContext.Map,
9999
algorithmSuiteID: AlgorithmSuite.ID,
100-
signingKey: Option<seq<uint8>>): ValidEncryptionMaterials
100+
signingKey: Option<seq<uint8>>): ValidEncryptionMaterials
101101
requires algorithmSuiteID.SignatureType().Some? ==> signingKey.Some?
102102
{
103103
var m := EncryptionMaterials(encryptionContext, algorithmSuiteID, None, [], [], signingKey);
104104
assert m.Valid();
105105
m
106106
}
107107

108-
function method WithKeys(newPlaintextDataKey: Option<seq<uint8>>,
108+
function method WithKeys(newPlaintextDataKey: Option<seq<uint8>>,
109109
newEncryptedDataKeys: seq<ValidEncryptedDataKey>,
110110
newTraceEntries: seq<KeyringTraceEntry>): (res: ValidEncryptionMaterials)
111111
requires Valid()
@@ -117,13 +117,13 @@ module {:extern "Materials"} Materials {
117117
requires (newPlaintextDataKey == this.plaintextDataKey) ==> (forall entry :: entry in newTraceEntries ==> !IsGenerateTraceEntry(entry))
118118
requires |Filter(newTraceEntries, IsEncryptTraceEntry)| == |newEncryptedDataKeys|
119119
ensures this.encryptionContext == res.encryptionContext
120-
ensures this.algorithmSuiteID == res.algorithmSuiteID
120+
ensures this.algorithmSuiteID == res.algorithmSuiteID
121121
ensures newPlaintextDataKey == res.plaintextDataKey
122122
ensures this.keyringTrace + newTraceEntries == res.keyringTrace
123123
ensures this.encryptedDataKeys + newEncryptedDataKeys == res.encryptedDataKeys
124124
ensures this.signingKey == res.signingKey
125125
{
126-
var r := this.(plaintextDataKey := newPlaintextDataKey,
126+
var r := this.(plaintextDataKey := newPlaintextDataKey,
127127
encryptedDataKeys := encryptedDataKeys + newEncryptedDataKeys,
128128
keyringTrace := keyringTrace + newTraceEntries);
129129
FilterIsDistributive(keyringTrace, newTraceEntries, IsEncryptTraceEntry);
@@ -155,7 +155,7 @@ module {:extern "Materials"} Materials {
155155

156156
static function method WithoutPlaintextDataKey(encryptionContext: EncryptionContext.Map,
157157
algorithmSuiteID: AlgorithmSuite.ID,
158-
verificationKey: Option<seq<uint8>>): ValidDecryptionMaterials
158+
verificationKey: Option<seq<uint8>>): ValidDecryptionMaterials
159159
requires algorithmSuiteID.SignatureType().Some? ==> verificationKey.Some?
160160
{
161161
var m := DecryptionMaterials(algorithmSuiteID, encryptionContext, None, verificationKey, []);
@@ -174,7 +174,7 @@ module {:extern "Materials"} Materials {
174174
ensures this.keyringTrace <= res.keyringTrace
175175
ensures this.verificationKey == res.verificationKey
176176
{
177-
var m := this.(plaintextDataKey := Some(plaintextDataKey),
177+
var m := this.(plaintextDataKey := Some(plaintextDataKey),
178178
keyringTrace := this.keyringTrace + newTraceEntries);
179179
assert m.Valid();
180180
m

src/StandardLibrary/Base64.dfy

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ module Base64 {
172172
if |b| == 0 then []
173173
else EncodeBlock(b[..3]) + EncodeRecursively(b[3..])
174174
}
175-
175+
176176
lemma DecodeEncodeRecursively(s: seq<index>)
177177
requires |s| % 4 == 0
178178
ensures EncodeRecursively(DecodeRecursively(s)) == s

src/api/dotnet/Client.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ public static MemoryStream Encrypt(EncryptRequest request) {
2020
STL.Result<ibyteseq> result = ESDKClient.__default.Encrypt(request.GetDafnyRequest());
2121
return DafnyFFI.MemoryStreamFromSequence(DafnyFFI.ExtractResult(result));
2222
}
23-
23+
2424
// TODO: Proper documentation
2525
public static MemoryStream Decrypt(DecryptRequest request) {
2626
// TODO: Might need a lock here if ANYTHING in the Dafny runtime isn't threadsafe!
2727
STL.Result<ibyteseq> result = ESDKClient.__default.Decrypt(request.GetDafnyRequest());
28-
28+
2929
return DafnyFFI.MemoryStreamFromSequence(DafnyFFI.ExtractResult(result));
3030
}
31-
31+
3232
private static encryptioncontext ToDafnyEncryptionContext(Dictionary<string, string> encryptionContext)
3333
{
3434
IEnumerable<Pair<ibyteseq, ibyteseq>> e = encryptionContext.Select(entry
@@ -65,7 +65,7 @@ internal ESDKClient.EncryptRequest GetDafnyRequest() {
6565
};
6666
}
6767
}
68-
68+
6969
public class DecryptRequest {
7070
public MemoryStream message { get; set;}
7171
public CMM cmm { get; set;}

0 commit comments

Comments
 (0)