Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import software.amazon.cryptography.primitives.internaldafny.types.Error;
import software.amazon.cryptography.primitives.model.AwsCryptographicPrimitivesError;

public class HMac extends _ExternBase_HMac {
public class HMac extends _ExternBase___default {

private String algorithm;
private Mac hmac;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def Digest(input: HMacInput):
output = hmac.GetResult()
return Wrappers.Result_Success(_dafny.Seq(output))

# Extend generated class
class HMac(aws_cryptography_primitives.internaldafny.generated.HMAC.HMac):
class HMac:

@staticmethod
def Build(digest):
Expand Down
16 changes: 9 additions & 7 deletions AwsCryptographyPrimitives/src/HKDF/HMAC.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,7 @@ module {:options "-functionSyntax:4"} {:extern "HMAC"} HMAC {
// since their calling pattern is different between different versions of Dafny
// (i.e. after 4.2, explicit type descriptors are required).

static function CreateHMacSuccess(hmac: HMac): Result<HMac, Types.Error> {
Success(hmac)
}

static function CreateHMacFailure(error: Types.Error): Result<HMac, Types.Error> {
Failure(error)
}
}

// HMAC Digest is safe to make a Dafny function
Expand All @@ -78,11 +72,19 @@ module {:options "-functionSyntax:4"} {:extern "HMAC"} HMAC {
: ( output: Result<seq<uint8>, Types.Error> )
ensures output.Success? ==> |output.value| == HashDigest.Length(input.digestAlgorithm)

// The next two functions are for the benefit of the extern implementation to call,
// The following functions are for the benefit of the extern implementation to call,
// avoiding direct references to generic datatype constructors
// since their calling pattern is different between different versions of Dafny
// (i.e. after 4.2, explicit type descriptors are required).

function CreateHMacSuccess(hmac: HMac): Result<HMac, Types.Error> {
Success(hmac)
}

function CreateHMacFailure(error: Types.Error): Result<HMac, Types.Error> {
Failure(error)
}

function CreateDigestSuccess(bytes: seq<uint8>): Result<seq<uint8>, Types.Error> {
Success(bytes)
}
Expand Down