github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl@v0.2.0/EdkWrapping/EdkWrapping.go (about)

     1  // Package EdkWrapping
     2  // Dafny module EdkWrapping compiled into Go
     3  
     4  package EdkWrapping
     5  
     6  import (
     7  	os "os"
     8  
     9  	m_ComAmazonawsDynamodbTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/dynamodb/ComAmazonawsDynamodbTypes"
    10  	m_Com_Amazonaws_Dynamodb "github.com/aws/aws-cryptographic-material-providers-library/releases/go/dynamodb/Com_Amazonaws_Dynamodb"
    11  	m_ComAmazonawsKmsTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/kms/ComAmazonawsKmsTypes"
    12  	m_Com_Amazonaws_Kms "github.com/aws/aws-cryptographic-material-providers-library/releases/go/kms/Com_Amazonaws_Kms"
    13  	m_AlgorithmSuites "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AlgorithmSuites"
    14  	m_AwsArnParsing "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsArnParsing"
    15  	m_AwsCryptographyKeyStoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsCryptographyKeyStoreOperations"
    16  	m_AwsCryptographyKeyStoreTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsCryptographyKeyStoreTypes"
    17  	m_AwsCryptographyMaterialProvidersTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsCryptographyMaterialProvidersTypes"
    18  	m_AwsKmsMrkAreUnique "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkAreUnique"
    19  	m_AwsKmsMrkMatchForDecrypt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkMatchForDecrypt"
    20  	m_AwsKmsUtils "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsUtils"
    21  	m_CanonicalEncryptionContext "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CanonicalEncryptionContext"
    22  	m_Constants "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Constants"
    23  	m_CreateKeyStoreTable "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeyStoreTable"
    24  	m_CreateKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeys"
    25  	m_DDBKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/DDBKeystoreOperations"
    26  	m_GetKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/GetKeys"
    27  	m_IntermediateKeyWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/IntermediateKeyWrapping"
    28  	m_KMSKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KMSKeystoreOperations"
    29  	m_KeyStore "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStore"
    30  	m_KeyStoreErrorMessages "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStoreErrorMessages"
    31  	m_Keyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Keyring"
    32  	m_KmsArn "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KmsArn"
    33  	m_MaterialWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MaterialWrapping"
    34  	m_Materials "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Materials"
    35  	m_MultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MultiKeyring"
    36  	m_Structure "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Structure"
    37  	m_AtomicPrimitives "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AtomicPrimitives"
    38  	m_AwsCryptographyPrimitivesOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesOperations"
    39  	m_AwsCryptographyPrimitivesTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesTypes"
    40  	m_Digest "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Digest"
    41  	m_HKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/HKDF"
    42  	m_KdfCtr "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/KdfCtr"
    43  	m_Random "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Random"
    44  	m_WrappedHKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHKDF"
    45  	m_WrappedHMAC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHMAC"
    46  	m_Actions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Actions"
    47  	m_Base64 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64"
    48  	m_Base64Lemmas "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64Lemmas"
    49  	m_BoundedInts "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/BoundedInts"
    50  	m_DivInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternals"
    51  	m_DivInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternalsNonlinear"
    52  	m_DivMod "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivMod"
    53  	m_FileIO "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FileIO"
    54  	m_FloatCompare "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FloatCompare"
    55  	m_Functions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Functions"
    56  	m_GeneralInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GeneralInternals"
    57  	m_GetOpt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GetOpt"
    58  	m_HexStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/HexStrings"
    59  	m_Logarithm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Logarithm"
    60  	m__Math "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Math_"
    61  	m_ModInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternals"
    62  	m_ModInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternalsNonlinear"
    63  	m_Mul "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Mul"
    64  	m_MulInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternals"
    65  	m_MulInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternalsNonlinear"
    66  	m_Power "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Power"
    67  	m_Relations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Relations"
    68  	m_Seq "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq"
    69  	m_Seq_MergeSort "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq_MergeSort"
    70  	m_Sorting "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Sorting"
    71  	m_StandardLibrary "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary"
    72  	m_StandardLibraryInterop "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibraryInterop"
    73  	m_StandardLibrary_Sequence "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_Sequence"
    74  	m_StandardLibrary_String "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_String"
    75  	m_StandardLibrary_UInt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_UInt"
    76  	m_Streams "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Streams"
    77  	m_UnicodeStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UnicodeStrings"
    78  	m__Unicode "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Unicode_"
    79  	m_Utf16EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf16EncodingForm"
    80  	m_Utf8EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf8EncodingForm"
    81  	m_Wrappers "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers"
    82  	m__System "github.com/dafny-lang/DafnyRuntimeGo/v4/System_"
    83  	_dafny "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny"
    84  )
    85  
    86  var _ = os.Args
    87  var _ _dafny.Dummy__
    88  var _ m__System.Dummy__
    89  var _ m_Wrappers.Dummy__
    90  var _ m_BoundedInts.Dummy__
    91  var _ m_StandardLibrary_UInt.Dummy__
    92  var _ m_StandardLibrary_Sequence.Dummy__
    93  var _ m_StandardLibrary_String.Dummy__
    94  var _ m_StandardLibrary.Dummy__
    95  var _ m_AwsCryptographyPrimitivesTypes.Dummy__
    96  var _ m_Random.Dummy__
    97  var _ m_Digest.Dummy__
    98  var _ m_WrappedHMAC.Dummy__
    99  var _ m_HKDF.Dummy__
   100  var _ m_WrappedHKDF.Dummy__
   101  var _ m_KdfCtr.Dummy__
   102  var _ m_AwsCryptographyPrimitivesOperations.Dummy__
   103  var _ m_AtomicPrimitives.Dummy__
   104  var _ m_ComAmazonawsDynamodbTypes.Dummy__
   105  var _ m_ComAmazonawsKmsTypes.Dummy__
   106  var _ m_Relations.Dummy__
   107  var _ m_Seq_MergeSort.Dummy__
   108  var _ m__Math.Dummy__
   109  var _ m_Seq.Dummy__
   110  var _ m__Unicode.Dummy__
   111  var _ m_Functions.Dummy__
   112  var _ m_Utf8EncodingForm.Dummy__
   113  var _ m_Utf16EncodingForm.Dummy__
   114  var _ m_UnicodeStrings.Dummy__
   115  var _ m_FileIO.Dummy__
   116  var _ m_GeneralInternals.Dummy__
   117  var _ m_MulInternalsNonlinear.Dummy__
   118  var _ m_MulInternals.Dummy__
   119  var _ m_Mul.Dummy__
   120  var _ m_ModInternalsNonlinear.Dummy__
   121  var _ m_DivInternalsNonlinear.Dummy__
   122  var _ m_ModInternals.Dummy__
   123  var _ m_DivInternals.Dummy__
   124  var _ m_DivMod.Dummy__
   125  var _ m_Power.Dummy__
   126  var _ m_Logarithm.Dummy__
   127  var _ m_StandardLibraryInterop.Dummy__
   128  var _ m_Streams.Dummy__
   129  var _ m_Sorting.Dummy__
   130  var _ m_HexStrings.Dummy__
   131  var _ m_GetOpt.Dummy__
   132  var _ m_FloatCompare.Dummy__
   133  var _ m_Base64.Dummy__
   134  var _ m_Base64Lemmas.Dummy__
   135  var _ m_Actions.Dummy__
   136  var _ m_AwsCryptographyKeyStoreTypes.Dummy__
   137  var _ m_AwsCryptographyMaterialProvidersTypes.Dummy__
   138  var _ m_AwsArnParsing.Dummy__
   139  var _ m_AwsKmsMrkMatchForDecrypt.Dummy__
   140  var _ m_AwsKmsUtils.Dummy__
   141  var _ m_KeyStoreErrorMessages.Dummy__
   142  var _ m_KmsArn.Dummy__
   143  var _ m_Structure.Dummy__
   144  var _ m_KMSKeystoreOperations.Dummy__
   145  var _ m_DDBKeystoreOperations.Dummy__
   146  var _ m_CreateKeys.Dummy__
   147  var _ m_CreateKeyStoreTable.Dummy__
   148  var _ m_GetKeys.Dummy__
   149  var _ m_AwsCryptographyKeyStoreOperations.Dummy__
   150  var _ m_Com_Amazonaws_Kms.Dummy__
   151  var _ m_Com_Amazonaws_Dynamodb.Dummy__
   152  var _ m_KeyStore.Dummy__
   153  var _ m_AlgorithmSuites.Dummy__
   154  var _ m_Materials.Dummy__
   155  var _ m_Keyring.Dummy__
   156  var _ m_MultiKeyring.Dummy__
   157  var _ m_AwsKmsMrkAreUnique.Dummy__
   158  var _ m_Constants.Dummy__
   159  var _ m_MaterialWrapping.Dummy__
   160  var _ m_CanonicalEncryptionContext.Dummy__
   161  var _ m_IntermediateKeyWrapping.Dummy__
   162  
   163  type Dummy__ struct{}
   164  
   165  // Definition of class Default__
   166  type Default__ struct {
   167  	dummy byte
   168  }
   169  
   170  func New_Default___() *Default__ {
   171  	_this := Default__{}
   172  
   173  	return &_this
   174  }
   175  
   176  type CompanionStruct_Default___ struct {
   177  }
   178  
   179  var Companion_Default___ = CompanionStruct_Default___{}
   180  
   181  func (_this *Default__) Equals(other *Default__) bool {
   182  	return _this == other
   183  }
   184  
   185  func (_this *Default__) EqualsGeneric(x interface{}) bool {
   186  	other, ok := x.(*Default__)
   187  	return ok && _this.Equals(other)
   188  }
   189  
   190  func (*Default__) String() string {
   191  	return "EdkWrapping.Default__"
   192  }
   193  func (_this *Default__) ParentTraits_() []*_dafny.TraitID {
   194  	return [](*_dafny.TraitID){}
   195  }
   196  
   197  var _ _dafny.TraitOffspring = &Default__{}
   198  
   199  func (_static *CompanionStruct_Default___) WrapEdkMaterial(encryptionMaterials m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials, wrap m_MaterialWrapping.WrapMaterial, generateAndWrap m_MaterialWrapping.GenerateAndWrapMaterial) m_Wrappers.Result {
   200  	var ret m_Wrappers.Result = m_Wrappers.Result{}
   201  	_ = ret
   202  	var _0_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   203  	_ = _0_valueOrError0
   204  	_0_valueOrError0 = m_Wrappers.Companion_Default___.Need(m_Materials.Companion_Default___.ValidEncryptionMaterials(encryptionMaterials), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid materials for encryption.")))
   205  	if (_0_valueOrError0).IsFailure() {
   206  		ret = (_0_valueOrError0).PropagateFailure()
   207  		return ret
   208  	}
   209  	if (((encryptionMaterials).Dtor_plaintextDataKey()).Is_Some()) && ((((encryptionMaterials).Dtor_algorithmSuite()).Dtor_edkWrapping()).Is_DIRECT__KEY__WRAPPING()) {
   210  		var _1_valueOrError1 m_Wrappers.Result = m_Wrappers.Result{}
   211  		_ = _1_valueOrError1
   212  		var _out0 interface{}
   213  		_ = _out0
   214  		_out0 = (wrap).Invoke(m_MaterialWrapping.Companion_WrapInput_.Create_WrapInput_(((encryptionMaterials).Dtor_plaintextDataKey()).Dtor_value().(_dafny.Sequence), (encryptionMaterials).Dtor_algorithmSuite(), (encryptionMaterials).Dtor_encryptionContext()))
   215  		_1_valueOrError1 = _out0.(m_Wrappers.Result)
   216  		if (_1_valueOrError1).IsFailure() {
   217  			ret = (_1_valueOrError1).PropagateFailure()
   218  			return ret
   219  		}
   220  		var _2_directOutput m_MaterialWrapping.WrapOutput
   221  		_ = _2_directOutput
   222  		_2_directOutput = (_1_valueOrError1).Extract().(m_MaterialWrapping.WrapOutput)
   223  		ret = m_Wrappers.Companion_Result_.Create_Success_(Companion_WrapEdkMaterialOutput_.Create_WrapOnlyEdkMaterialOutput_((_2_directOutput).Dtor_wrappedMaterial(), m_Wrappers.Companion_Option_.Create_None_(), (_2_directOutput).Dtor_wrapInfo()))
   224  		return ret
   225  	} else if (((encryptionMaterials).Dtor_plaintextDataKey()).Is_Some()) && ((((encryptionMaterials).Dtor_algorithmSuite()).Dtor_edkWrapping()).Is_IntermediateKeyWrapping()) {
   226  		var _3_valueOrError2 m_Wrappers.Result = m_Wrappers.Result{}
   227  		_ = _3_valueOrError2
   228  		var _out1 m_Wrappers.Result
   229  		_ = _out1
   230  		_out1 = m_IntermediateKeyWrapping.Companion_Default___.IntermediateWrap(generateAndWrap, ((encryptionMaterials).Dtor_plaintextDataKey()).Dtor_value().(_dafny.Sequence), (encryptionMaterials).Dtor_algorithmSuite(), (encryptionMaterials).Dtor_encryptionContext())
   231  		_3_valueOrError2 = _out1
   232  		if (_3_valueOrError2).IsFailure() {
   233  			ret = (_3_valueOrError2).PropagateFailure()
   234  			return ret
   235  		}
   236  		var _4_intermediateOutput m_IntermediateKeyWrapping.IntermediateWrapOutput
   237  		_ = _4_intermediateOutput
   238  		_4_intermediateOutput = (_3_valueOrError2).Extract().(m_IntermediateKeyWrapping.IntermediateWrapOutput)
   239  		ret = m_Wrappers.Companion_Result_.Create_Success_(Companion_WrapEdkMaterialOutput_.Create_WrapOnlyEdkMaterialOutput_((_4_intermediateOutput).Dtor_wrappedMaterial(), m_Wrappers.Companion_Option_.Create_Some_((_4_intermediateOutput).Dtor_symmetricSigningKey()), (_4_intermediateOutput).Dtor_wrapInfo()))
   240  		return ret
   241  	} else if (((encryptionMaterials).Dtor_plaintextDataKey()).Is_None()) && ((((encryptionMaterials).Dtor_algorithmSuite()).Dtor_edkWrapping()).Is_DIRECT__KEY__WRAPPING()) {
   242  		var _5_valueOrError3 m_Wrappers.Result = m_Wrappers.Result{}
   243  		_ = _5_valueOrError3
   244  		var _out2 interface{}
   245  		_ = _out2
   246  		_out2 = (generateAndWrap).Invoke(m_MaterialWrapping.Companion_GenerateAndWrapInput_.Create_GenerateAndWrapInput_((encryptionMaterials).Dtor_algorithmSuite(), (encryptionMaterials).Dtor_encryptionContext()))
   247  		_5_valueOrError3 = _out2.(m_Wrappers.Result)
   248  		if (_5_valueOrError3).IsFailure() {
   249  			ret = (_5_valueOrError3).PropagateFailure()
   250  			return ret
   251  		}
   252  		var _6_directOutput m_MaterialWrapping.GenerateAndWrapOutput
   253  		_ = _6_directOutput
   254  		_6_directOutput = (_5_valueOrError3).Extract().(m_MaterialWrapping.GenerateAndWrapOutput)
   255  		ret = m_Wrappers.Companion_Result_.Create_Success_(Companion_WrapEdkMaterialOutput_.Create_GenerateAndWrapEdkMaterialOutput_((_6_directOutput).Dtor_plaintextMaterial(), (_6_directOutput).Dtor_wrappedMaterial(), m_Wrappers.Companion_Option_.Create_None_(), (_6_directOutput).Dtor_wrapInfo()))
   256  		return ret
   257  	} else if (((encryptionMaterials).Dtor_plaintextDataKey()).Is_None()) && ((((encryptionMaterials).Dtor_algorithmSuite()).Dtor_edkWrapping()).Is_IntermediateKeyWrapping()) {
   258  		var _7_valueOrError4 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   259  		_ = _7_valueOrError4
   260  		_7_valueOrError4 = m_Wrappers.Companion_Default___.Need((((encryptionMaterials).Dtor_algorithmSuite()).Dtor_commitment()).Is_HKDF(), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid algorithm suite: suites with intermediate key wrapping must use key commitment.")))
   261  		if (_7_valueOrError4).IsFailure() {
   262  			ret = (_7_valueOrError4).PropagateFailure()
   263  			return ret
   264  		}
   265  		var _8_valueOrError5 m_Wrappers.Result = m_Wrappers.Result{}
   266  		_ = _8_valueOrError5
   267  		var _out3 m_Wrappers.Result
   268  		_ = _out3
   269  		_out3 = m_IntermediateKeyWrapping.Companion_Default___.IntermediateGenerateAndWrap(generateAndWrap, (encryptionMaterials).Dtor_algorithmSuite(), (encryptionMaterials).Dtor_encryptionContext())
   270  		_8_valueOrError5 = _out3
   271  		if (_8_valueOrError5).IsFailure() {
   272  			ret = (_8_valueOrError5).PropagateFailure()
   273  			return ret
   274  		}
   275  		var _9_intermediateOutput m_IntermediateKeyWrapping.IntermediateGenerateAndWrapOutput
   276  		_ = _9_intermediateOutput
   277  		_9_intermediateOutput = (_8_valueOrError5).Extract().(m_IntermediateKeyWrapping.IntermediateGenerateAndWrapOutput)
   278  		ret = m_Wrappers.Companion_Result_.Create_Success_(Companion_WrapEdkMaterialOutput_.Create_GenerateAndWrapEdkMaterialOutput_((_9_intermediateOutput).Dtor_plaintextDataKey(), (_9_intermediateOutput).Dtor_wrappedMaterial(), m_Wrappers.Companion_Option_.Create_Some_((_9_intermediateOutput).Dtor_symmetricSigningKey()), (_9_intermediateOutput).Dtor_wrapInfo()))
   279  		return ret
   280  	} else {
   281  	}
   282  	return ret
   283  }
   284  func (_static *CompanionStruct_Default___) UnwrapEdkMaterial(wrappedMaterial _dafny.Sequence, decryptionMaterials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials, unwrap m_MaterialWrapping.UnwrapMaterial) m_Wrappers.Result {
   285  	var ret m_Wrappers.Result = m_Wrappers.Result{}
   286  	_ = ret
   287  	var _0_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   288  	_ = _0_valueOrError0
   289  	_0_valueOrError0 = m_Wrappers.Companion_Default___.Need(m_Materials.Companion_Default___.ValidDecryptionMaterials(decryptionMaterials), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid materials for decryption.")))
   290  	if (_0_valueOrError0).IsFailure() {
   291  		ret = (_0_valueOrError0).PropagateFailure()
   292  		return ret
   293  	}
   294  	if (((decryptionMaterials).Dtor_algorithmSuite()).Dtor_edkWrapping()).Is_DIRECT__KEY__WRAPPING() {
   295  		var _1_valueOrError1 m_Wrappers.Result = m_Wrappers.Result{}
   296  		_ = _1_valueOrError1
   297  		var _out0 interface{}
   298  		_ = _out0
   299  		_out0 = (unwrap).Invoke(m_MaterialWrapping.Companion_UnwrapInput_.Create_UnwrapInput_(wrappedMaterial, (decryptionMaterials).Dtor_algorithmSuite(), (decryptionMaterials).Dtor_encryptionContext()))
   300  		_1_valueOrError1 = _out0.(m_Wrappers.Result)
   301  		if (_1_valueOrError1).IsFailure() {
   302  			ret = (_1_valueOrError1).PropagateFailure()
   303  			return ret
   304  		}
   305  		var _2_directOutput m_MaterialWrapping.UnwrapOutput
   306  		_ = _2_directOutput
   307  		_2_directOutput = (_1_valueOrError1).Extract().(m_MaterialWrapping.UnwrapOutput)
   308  		ret = m_Wrappers.Companion_Result_.Create_Success_(Companion_UnwrapEdkMaterialOutput_.Create_UnwrapEdkMaterialOutput_((_2_directOutput).Dtor_unwrappedMaterial(), m_Wrappers.Companion_Option_.Create_None_(), (_2_directOutput).Dtor_unwrapInfo()))
   309  		return ret
   310  	} else if (((decryptionMaterials).Dtor_algorithmSuite()).Dtor_edkWrapping()).Is_IntermediateKeyWrapping() {
   311  		var _3_valueOrError2 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   312  		_ = _3_valueOrError2
   313  		_3_valueOrError2 = m_Wrappers.Companion_Default___.Need((_dafny.IntOfUint32((wrappedMaterial).Cardinality())).Cmp(_dafny.IntOfInt32((((((decryptionMaterials).Dtor_algorithmSuite()).Dtor_encrypt()).Dtor_AES__GCM()).Dtor_keyLength())+(((((decryptionMaterials).Dtor_algorithmSuite()).Dtor_encrypt()).Dtor_AES__GCM()).Dtor_tagLength()))) >= 0, m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid material for Intermediate Unwrapping")))
   314  		if (_3_valueOrError2).IsFailure() {
   315  			ret = (_3_valueOrError2).PropagateFailure()
   316  			return ret
   317  		}
   318  		var _4_valueOrError3 m_Wrappers.Result = m_Wrappers.Result{}
   319  		_ = _4_valueOrError3
   320  		var _out1 m_Wrappers.Result
   321  		_ = _out1
   322  		_out1 = m_IntermediateKeyWrapping.Companion_Default___.IntermediateUnwrap(unwrap, wrappedMaterial, (decryptionMaterials).Dtor_algorithmSuite(), (decryptionMaterials).Dtor_encryptionContext())
   323  		_4_valueOrError3 = _out1
   324  		if (_4_valueOrError3).IsFailure() {
   325  			ret = (_4_valueOrError3).PropagateFailure()
   326  			return ret
   327  		}
   328  		var _5_intermediateOutput m_IntermediateKeyWrapping.IntermediateUnwrapOutput
   329  		_ = _5_intermediateOutput
   330  		_5_intermediateOutput = (_4_valueOrError3).Extract().(m_IntermediateKeyWrapping.IntermediateUnwrapOutput)
   331  		ret = m_Wrappers.Companion_Result_.Create_Success_(Companion_UnwrapEdkMaterialOutput_.Create_UnwrapEdkMaterialOutput_((_5_intermediateOutput).Dtor_plaintextDataKey(), m_Wrappers.Companion_Option_.Create_Some_((_5_intermediateOutput).Dtor_symmetricSigningKey()), (_5_intermediateOutput).Dtor_unwrapInfo()))
   332  		return ret
   333  	} else {
   334  	}
   335  	return ret
   336  }
   337  func (_static *CompanionStruct_Default___) GetProviderWrappedMaterial(material _dafny.Sequence, algSuite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo) m_Wrappers.Result {
   338  	if ((algSuite).Dtor_edkWrapping()).Is_DIRECT__KEY__WRAPPING() {
   339  		return m_Wrappers.Companion_Result_.Create_Success_(material)
   340  	} else {
   341  		var _0_deserializedWrappedRes m_Wrappers.Result = m_IntermediateKeyWrapping.Companion_Default___.DeserializeIntermediateWrappedMaterial(material, algSuite)
   342  		_ = _0_deserializedWrappedRes
   343  		if (_0_deserializedWrappedRes).Is_Failure() {
   344  			return m_Wrappers.Companion_Result_.Create_Failure_(m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Unable to deserialize Intermediate Key Wrapped material.")))
   345  		} else {
   346  			return m_Wrappers.Companion_Result_.Create_Success_(((_0_deserializedWrappedRes).Dtor_value().(m_IntermediateKeyWrapping.DeserializedIntermediateWrappedMaterial)).Dtor_providerWrappedIkm())
   347  		}
   348  	}
   349  }
   350  
   351  // End of class Default__
   352  
   353  // Definition of datatype WrapEdkMaterialOutput
   354  type WrapEdkMaterialOutput struct {
   355  	Data_WrapEdkMaterialOutput_
   356  }
   357  
   358  func (_this WrapEdkMaterialOutput) Get_() Data_WrapEdkMaterialOutput_ {
   359  	return _this.Data_WrapEdkMaterialOutput_
   360  }
   361  
   362  type Data_WrapEdkMaterialOutput_ interface {
   363  	isWrapEdkMaterialOutput()
   364  }
   365  
   366  type CompanionStruct_WrapEdkMaterialOutput_ struct {
   367  }
   368  
   369  var Companion_WrapEdkMaterialOutput_ = CompanionStruct_WrapEdkMaterialOutput_{}
   370  
   371  type WrapEdkMaterialOutput_WrapOnlyEdkMaterialOutput struct {
   372  	WrappedMaterial     _dafny.Sequence
   373  	SymmetricSigningKey m_Wrappers.Option
   374  	WrapInfo            interface{}
   375  }
   376  
   377  func (WrapEdkMaterialOutput_WrapOnlyEdkMaterialOutput) isWrapEdkMaterialOutput() {}
   378  
   379  func (CompanionStruct_WrapEdkMaterialOutput_) Create_WrapOnlyEdkMaterialOutput_(WrappedMaterial _dafny.Sequence, SymmetricSigningKey m_Wrappers.Option, WrapInfo interface{}) WrapEdkMaterialOutput {
   380  	return WrapEdkMaterialOutput{WrapEdkMaterialOutput_WrapOnlyEdkMaterialOutput{WrappedMaterial, SymmetricSigningKey, WrapInfo}}
   381  }
   382  
   383  func (_this WrapEdkMaterialOutput) Is_WrapOnlyEdkMaterialOutput() bool {
   384  	_, ok := _this.Get_().(WrapEdkMaterialOutput_WrapOnlyEdkMaterialOutput)
   385  	return ok
   386  }
   387  
   388  type WrapEdkMaterialOutput_GenerateAndWrapEdkMaterialOutput struct {
   389  	PlaintextDataKey    _dafny.Sequence
   390  	WrappedMaterial     _dafny.Sequence
   391  	SymmetricSigningKey m_Wrappers.Option
   392  	WrapInfo            interface{}
   393  }
   394  
   395  func (WrapEdkMaterialOutput_GenerateAndWrapEdkMaterialOutput) isWrapEdkMaterialOutput() {}
   396  
   397  func (CompanionStruct_WrapEdkMaterialOutput_) Create_GenerateAndWrapEdkMaterialOutput_(PlaintextDataKey _dafny.Sequence, WrappedMaterial _dafny.Sequence, SymmetricSigningKey m_Wrappers.Option, WrapInfo interface{}) WrapEdkMaterialOutput {
   398  	return WrapEdkMaterialOutput{WrapEdkMaterialOutput_GenerateAndWrapEdkMaterialOutput{PlaintextDataKey, WrappedMaterial, SymmetricSigningKey, WrapInfo}}
   399  }
   400  
   401  func (_this WrapEdkMaterialOutput) Is_GenerateAndWrapEdkMaterialOutput() bool {
   402  	_, ok := _this.Get_().(WrapEdkMaterialOutput_GenerateAndWrapEdkMaterialOutput)
   403  	return ok
   404  }
   405  
   406  func (CompanionStruct_WrapEdkMaterialOutput_) Default(_default_T interface{}) WrapEdkMaterialOutput {
   407  	return Companion_WrapEdkMaterialOutput_.Create_WrapOnlyEdkMaterialOutput_(_dafny.EmptySeq, m_Wrappers.Companion_Option_.Default(), _default_T)
   408  }
   409  
   410  func (_this WrapEdkMaterialOutput) Dtor_wrappedMaterial() _dafny.Sequence {
   411  	switch data := _this.Get_().(type) {
   412  	case WrapEdkMaterialOutput_WrapOnlyEdkMaterialOutput:
   413  		return data.WrappedMaterial
   414  	default:
   415  		return data.(WrapEdkMaterialOutput_GenerateAndWrapEdkMaterialOutput).WrappedMaterial
   416  	}
   417  }
   418  
   419  func (_this WrapEdkMaterialOutput) Dtor_symmetricSigningKey() m_Wrappers.Option {
   420  	switch data := _this.Get_().(type) {
   421  	case WrapEdkMaterialOutput_WrapOnlyEdkMaterialOutput:
   422  		return data.SymmetricSigningKey
   423  	default:
   424  		return data.(WrapEdkMaterialOutput_GenerateAndWrapEdkMaterialOutput).SymmetricSigningKey
   425  	}
   426  }
   427  
   428  func (_this WrapEdkMaterialOutput) Dtor_wrapInfo() interface{} {
   429  	switch data := _this.Get_().(type) {
   430  	case WrapEdkMaterialOutput_WrapOnlyEdkMaterialOutput:
   431  		return data.WrapInfo
   432  	default:
   433  		return data.(WrapEdkMaterialOutput_GenerateAndWrapEdkMaterialOutput).WrapInfo
   434  	}
   435  }
   436  
   437  func (_this WrapEdkMaterialOutput) Dtor_plaintextDataKey() _dafny.Sequence {
   438  	return _this.Get_().(WrapEdkMaterialOutput_GenerateAndWrapEdkMaterialOutput).PlaintextDataKey
   439  }
   440  
   441  func (_this WrapEdkMaterialOutput) String() string {
   442  	switch data := _this.Get_().(type) {
   443  	case nil:
   444  		return "null"
   445  	case WrapEdkMaterialOutput_WrapOnlyEdkMaterialOutput:
   446  		{
   447  			return "EdkWrapping.WrapEdkMaterialOutput.WrapOnlyEdkMaterialOutput" + "(" + _dafny.String(data.WrappedMaterial) + ", " + _dafny.String(data.SymmetricSigningKey) + ", " + _dafny.String(data.WrapInfo) + ")"
   448  		}
   449  	case WrapEdkMaterialOutput_GenerateAndWrapEdkMaterialOutput:
   450  		{
   451  			return "EdkWrapping.WrapEdkMaterialOutput.GenerateAndWrapEdkMaterialOutput" + "(" + _dafny.String(data.PlaintextDataKey) + ", " + _dafny.String(data.WrappedMaterial) + ", " + _dafny.String(data.SymmetricSigningKey) + ", " + _dafny.String(data.WrapInfo) + ")"
   452  		}
   453  	default:
   454  		{
   455  			return "<unexpected>"
   456  		}
   457  	}
   458  }
   459  
   460  func (_this WrapEdkMaterialOutput) Equals(other WrapEdkMaterialOutput) bool {
   461  	switch data1 := _this.Get_().(type) {
   462  	case WrapEdkMaterialOutput_WrapOnlyEdkMaterialOutput:
   463  		{
   464  			data2, ok := other.Get_().(WrapEdkMaterialOutput_WrapOnlyEdkMaterialOutput)
   465  			return ok && data1.WrappedMaterial.Equals(data2.WrappedMaterial) && data1.SymmetricSigningKey.Equals(data2.SymmetricSigningKey) && _dafny.AreEqual(data1.WrapInfo, data2.WrapInfo)
   466  		}
   467  	case WrapEdkMaterialOutput_GenerateAndWrapEdkMaterialOutput:
   468  		{
   469  			data2, ok := other.Get_().(WrapEdkMaterialOutput_GenerateAndWrapEdkMaterialOutput)
   470  			return ok && data1.PlaintextDataKey.Equals(data2.PlaintextDataKey) && data1.WrappedMaterial.Equals(data2.WrappedMaterial) && data1.SymmetricSigningKey.Equals(data2.SymmetricSigningKey) && _dafny.AreEqual(data1.WrapInfo, data2.WrapInfo)
   471  		}
   472  	default:
   473  		{
   474  			return false // unexpected
   475  		}
   476  	}
   477  }
   478  
   479  func (_this WrapEdkMaterialOutput) EqualsGeneric(other interface{}) bool {
   480  	typed, ok := other.(WrapEdkMaterialOutput)
   481  	return ok && _this.Equals(typed)
   482  }
   483  
   484  func Type_WrapEdkMaterialOutput_(Type_T_ _dafny.TypeDescriptor) _dafny.TypeDescriptor {
   485  	return type_WrapEdkMaterialOutput_{Type_T_}
   486  }
   487  
   488  type type_WrapEdkMaterialOutput_ struct {
   489  	Type_T_ _dafny.TypeDescriptor
   490  }
   491  
   492  func (_this type_WrapEdkMaterialOutput_) Default() interface{} {
   493  	Type_T_ := _this.Type_T_
   494  	_ = Type_T_
   495  	return Companion_WrapEdkMaterialOutput_.Default(Type_T_.Default())
   496  }
   497  
   498  func (_this type_WrapEdkMaterialOutput_) String() string {
   499  	return "EdkWrapping.WrapEdkMaterialOutput"
   500  }
   501  func (_this WrapEdkMaterialOutput) ParentTraits_() []*_dafny.TraitID {
   502  	return [](*_dafny.TraitID){}
   503  }
   504  
   505  var _ _dafny.TraitOffspring = WrapEdkMaterialOutput{}
   506  
   507  // End of datatype WrapEdkMaterialOutput
   508  
   509  // Definition of datatype UnwrapEdkMaterialOutput
   510  type UnwrapEdkMaterialOutput struct {
   511  	Data_UnwrapEdkMaterialOutput_
   512  }
   513  
   514  func (_this UnwrapEdkMaterialOutput) Get_() Data_UnwrapEdkMaterialOutput_ {
   515  	return _this.Data_UnwrapEdkMaterialOutput_
   516  }
   517  
   518  type Data_UnwrapEdkMaterialOutput_ interface {
   519  	isUnwrapEdkMaterialOutput()
   520  }
   521  
   522  type CompanionStruct_UnwrapEdkMaterialOutput_ struct {
   523  }
   524  
   525  var Companion_UnwrapEdkMaterialOutput_ = CompanionStruct_UnwrapEdkMaterialOutput_{}
   526  
   527  type UnwrapEdkMaterialOutput_UnwrapEdkMaterialOutput struct {
   528  	PlaintextDataKey    _dafny.Sequence
   529  	SymmetricSigningKey m_Wrappers.Option
   530  	UnwrapInfo          interface{}
   531  }
   532  
   533  func (UnwrapEdkMaterialOutput_UnwrapEdkMaterialOutput) isUnwrapEdkMaterialOutput() {}
   534  
   535  func (CompanionStruct_UnwrapEdkMaterialOutput_) Create_UnwrapEdkMaterialOutput_(PlaintextDataKey _dafny.Sequence, SymmetricSigningKey m_Wrappers.Option, UnwrapInfo interface{}) UnwrapEdkMaterialOutput {
   536  	return UnwrapEdkMaterialOutput{UnwrapEdkMaterialOutput_UnwrapEdkMaterialOutput{PlaintextDataKey, SymmetricSigningKey, UnwrapInfo}}
   537  }
   538  
   539  func (_this UnwrapEdkMaterialOutput) Is_UnwrapEdkMaterialOutput() bool {
   540  	_, ok := _this.Get_().(UnwrapEdkMaterialOutput_UnwrapEdkMaterialOutput)
   541  	return ok
   542  }
   543  
   544  func (CompanionStruct_UnwrapEdkMaterialOutput_) Default(_default_T interface{}) UnwrapEdkMaterialOutput {
   545  	return Companion_UnwrapEdkMaterialOutput_.Create_UnwrapEdkMaterialOutput_(_dafny.EmptySeq, m_Wrappers.Companion_Option_.Default(), _default_T)
   546  }
   547  
   548  func (_this UnwrapEdkMaterialOutput) Dtor_plaintextDataKey() _dafny.Sequence {
   549  	return _this.Get_().(UnwrapEdkMaterialOutput_UnwrapEdkMaterialOutput).PlaintextDataKey
   550  }
   551  
   552  func (_this UnwrapEdkMaterialOutput) Dtor_symmetricSigningKey() m_Wrappers.Option {
   553  	return _this.Get_().(UnwrapEdkMaterialOutput_UnwrapEdkMaterialOutput).SymmetricSigningKey
   554  }
   555  
   556  func (_this UnwrapEdkMaterialOutput) Dtor_unwrapInfo() interface{} {
   557  	return _this.Get_().(UnwrapEdkMaterialOutput_UnwrapEdkMaterialOutput).UnwrapInfo
   558  }
   559  
   560  func (_this UnwrapEdkMaterialOutput) String() string {
   561  	switch data := _this.Get_().(type) {
   562  	case nil:
   563  		return "null"
   564  	case UnwrapEdkMaterialOutput_UnwrapEdkMaterialOutput:
   565  		{
   566  			return "EdkWrapping.UnwrapEdkMaterialOutput.UnwrapEdkMaterialOutput" + "(" + _dafny.String(data.PlaintextDataKey) + ", " + _dafny.String(data.SymmetricSigningKey) + ", " + _dafny.String(data.UnwrapInfo) + ")"
   567  		}
   568  	default:
   569  		{
   570  			return "<unexpected>"
   571  		}
   572  	}
   573  }
   574  
   575  func (_this UnwrapEdkMaterialOutput) Equals(other UnwrapEdkMaterialOutput) bool {
   576  	switch data1 := _this.Get_().(type) {
   577  	case UnwrapEdkMaterialOutput_UnwrapEdkMaterialOutput:
   578  		{
   579  			data2, ok := other.Get_().(UnwrapEdkMaterialOutput_UnwrapEdkMaterialOutput)
   580  			return ok && data1.PlaintextDataKey.Equals(data2.PlaintextDataKey) && data1.SymmetricSigningKey.Equals(data2.SymmetricSigningKey) && _dafny.AreEqual(data1.UnwrapInfo, data2.UnwrapInfo)
   581  		}
   582  	default:
   583  		{
   584  			return false // unexpected
   585  		}
   586  	}
   587  }
   588  
   589  func (_this UnwrapEdkMaterialOutput) EqualsGeneric(other interface{}) bool {
   590  	typed, ok := other.(UnwrapEdkMaterialOutput)
   591  	return ok && _this.Equals(typed)
   592  }
   593  
   594  func Type_UnwrapEdkMaterialOutput_(Type_T_ _dafny.TypeDescriptor) _dafny.TypeDescriptor {
   595  	return type_UnwrapEdkMaterialOutput_{Type_T_}
   596  }
   597  
   598  type type_UnwrapEdkMaterialOutput_ struct {
   599  	Type_T_ _dafny.TypeDescriptor
   600  }
   601  
   602  func (_this type_UnwrapEdkMaterialOutput_) Default() interface{} {
   603  	Type_T_ := _this.Type_T_
   604  	_ = Type_T_
   605  	return Companion_UnwrapEdkMaterialOutput_.Default(Type_T_.Default())
   606  }
   607  
   608  func (_this type_UnwrapEdkMaterialOutput_) String() string {
   609  	return "EdkWrapping.UnwrapEdkMaterialOutput"
   610  }
   611  func (_this UnwrapEdkMaterialOutput) ParentTraits_() []*_dafny.TraitID {
   612  	return [](*_dafny.TraitID){}
   613  }
   614  
   615  var _ _dafny.TraitOffspring = UnwrapEdkMaterialOutput{}
   616  
   617  // End of datatype UnwrapEdkMaterialOutput