github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl@v0.2.0/RawRSAKeyring/RawRSAKeyring.go (about) 1 // Package RawRSAKeyring 2 // Dafny module RawRSAKeyring compiled into Go 3 4 package RawRSAKeyring 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_AwsKmsDiscoveryKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsDiscoveryKeyring" 19 m_AwsKmsEcdhKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsEcdhKeyring" 20 m_AwsKmsHierarchicalKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsHierarchicalKeyring" 21 m_AwsKmsKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsKeyring" 22 m_AwsKmsMrkAreUnique "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkAreUnique" 23 m_AwsKmsMrkDiscoveryKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkDiscoveryKeyring" 24 m_AwsKmsMrkKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkKeyring" 25 m_AwsKmsMrkMatchForDecrypt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkMatchForDecrypt" 26 m_AwsKmsRsaKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsRsaKeyring" 27 m_AwsKmsUtils "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsUtils" 28 m_CacheConstants "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CacheConstants" 29 m_CanonicalEncryptionContext "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CanonicalEncryptionContext" 30 m_Constants "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Constants" 31 m_CreateKeyStoreTable "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeyStoreTable" 32 m_CreateKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeys" 33 m_DDBKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/DDBKeystoreOperations" 34 m_DiscoveryMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/DiscoveryMultiKeyring" 35 m_EcdhEdkWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/EcdhEdkWrapping" 36 m_EdkWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/EdkWrapping" 37 m_ErrorMessages "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/ErrorMessages" 38 m_GetKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/GetKeys" 39 m_IntermediateKeyWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/IntermediateKeyWrapping" 40 m_KMSKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KMSKeystoreOperations" 41 m_KeyStore "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStore" 42 m_KeyStoreErrorMessages "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStoreErrorMessages" 43 m_Keyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Keyring" 44 m_KmsArn "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KmsArn" 45 m_LocalCMC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/LocalCMC" 46 m_MaterialWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MaterialWrapping" 47 m_Materials "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Materials" 48 m_MrkAwareDiscoveryMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MrkAwareDiscoveryMultiKeyring" 49 m_MrkAwareStrictMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MrkAwareStrictMultiKeyring" 50 m_MultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MultiKeyring" 51 m_RawAESKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/RawAESKeyring" 52 m_RawECDHKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/RawECDHKeyring" 53 m_StormTracker "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/StormTracker" 54 m_StormTrackingCMC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/StormTrackingCMC" 55 m_StrictMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/StrictMultiKeyring" 56 m_Structure "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Structure" 57 m_SynchronizedLocalCMC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/SynchronizedLocalCMC" 58 m_AtomicPrimitives "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AtomicPrimitives" 59 m_AwsCryptographyPrimitivesOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesOperations" 60 m_AwsCryptographyPrimitivesTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesTypes" 61 m_Digest "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Digest" 62 m_HKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/HKDF" 63 m_KdfCtr "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/KdfCtr" 64 m_Random "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Random" 65 m_WrappedHKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHKDF" 66 m_WrappedHMAC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHMAC" 67 m_Actions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Actions" 68 m_Base64 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64" 69 m_Base64Lemmas "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64Lemmas" 70 m_BoundedInts "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/BoundedInts" 71 m_DivInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternals" 72 m_DivInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternalsNonlinear" 73 m_DivMod "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivMod" 74 m_FileIO "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FileIO" 75 m_FloatCompare "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FloatCompare" 76 m_Functions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Functions" 77 m_GeneralInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GeneralInternals" 78 m_GetOpt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GetOpt" 79 m_HexStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/HexStrings" 80 m_Logarithm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Logarithm" 81 m__Math "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Math_" 82 m_ModInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternals" 83 m_ModInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternalsNonlinear" 84 m_Mul "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Mul" 85 m_MulInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternals" 86 m_MulInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternalsNonlinear" 87 m_Power "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Power" 88 m_Relations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Relations" 89 m_Seq "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq" 90 m_Seq_MergeSort "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq_MergeSort" 91 m_Sorting "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Sorting" 92 m_StandardLibrary "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary" 93 m_StandardLibraryInterop "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibraryInterop" 94 m_StandardLibrary_Sequence "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_Sequence" 95 m_StandardLibrary_String "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_String" 96 m_StandardLibrary_UInt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_UInt" 97 m_Streams "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Streams" 98 m_UTF8 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UTF8" 99 m_UnicodeStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UnicodeStrings" 100 m__Unicode "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Unicode_" 101 m_Utf16EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf16EncodingForm" 102 m_Utf8EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf8EncodingForm" 103 m_Wrappers "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers" 104 m__System "github.com/dafny-lang/DafnyRuntimeGo/v4/System_" 105 _dafny "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" 106 ) 107 108 var _ = os.Args 109 var _ _dafny.Dummy__ 110 var _ m__System.Dummy__ 111 var _ m_Wrappers.Dummy__ 112 var _ m_BoundedInts.Dummy__ 113 var _ m_StandardLibrary_UInt.Dummy__ 114 var _ m_StandardLibrary_Sequence.Dummy__ 115 var _ m_StandardLibrary_String.Dummy__ 116 var _ m_StandardLibrary.Dummy__ 117 var _ m_AwsCryptographyPrimitivesTypes.Dummy__ 118 var _ m_Random.Dummy__ 119 var _ m_Digest.Dummy__ 120 var _ m_WrappedHMAC.Dummy__ 121 var _ m_HKDF.Dummy__ 122 var _ m_WrappedHKDF.Dummy__ 123 var _ m_KdfCtr.Dummy__ 124 var _ m_AwsCryptographyPrimitivesOperations.Dummy__ 125 var _ m_AtomicPrimitives.Dummy__ 126 var _ m_ComAmazonawsDynamodbTypes.Dummy__ 127 var _ m_ComAmazonawsKmsTypes.Dummy__ 128 var _ m_Relations.Dummy__ 129 var _ m_Seq_MergeSort.Dummy__ 130 var _ m__Math.Dummy__ 131 var _ m_Seq.Dummy__ 132 var _ m__Unicode.Dummy__ 133 var _ m_Functions.Dummy__ 134 var _ m_Utf8EncodingForm.Dummy__ 135 var _ m_Utf16EncodingForm.Dummy__ 136 var _ m_UnicodeStrings.Dummy__ 137 var _ m_FileIO.Dummy__ 138 var _ m_GeneralInternals.Dummy__ 139 var _ m_MulInternalsNonlinear.Dummy__ 140 var _ m_MulInternals.Dummy__ 141 var _ m_Mul.Dummy__ 142 var _ m_ModInternalsNonlinear.Dummy__ 143 var _ m_DivInternalsNonlinear.Dummy__ 144 var _ m_ModInternals.Dummy__ 145 var _ m_DivInternals.Dummy__ 146 var _ m_DivMod.Dummy__ 147 var _ m_Power.Dummy__ 148 var _ m_Logarithm.Dummy__ 149 var _ m_StandardLibraryInterop.Dummy__ 150 var _ m_Streams.Dummy__ 151 var _ m_Sorting.Dummy__ 152 var _ m_HexStrings.Dummy__ 153 var _ m_GetOpt.Dummy__ 154 var _ m_FloatCompare.Dummy__ 155 var _ m_Base64.Dummy__ 156 var _ m_Base64Lemmas.Dummy__ 157 var _ m_Actions.Dummy__ 158 var _ m_AwsCryptographyKeyStoreTypes.Dummy__ 159 var _ m_AwsCryptographyMaterialProvidersTypes.Dummy__ 160 var _ m_AwsArnParsing.Dummy__ 161 var _ m_AwsKmsMrkMatchForDecrypt.Dummy__ 162 var _ m_AwsKmsUtils.Dummy__ 163 var _ m_KeyStoreErrorMessages.Dummy__ 164 var _ m_KmsArn.Dummy__ 165 var _ m_Structure.Dummy__ 166 var _ m_KMSKeystoreOperations.Dummy__ 167 var _ m_DDBKeystoreOperations.Dummy__ 168 var _ m_CreateKeys.Dummy__ 169 var _ m_CreateKeyStoreTable.Dummy__ 170 var _ m_GetKeys.Dummy__ 171 var _ m_AwsCryptographyKeyStoreOperations.Dummy__ 172 var _ m_Com_Amazonaws_Kms.Dummy__ 173 var _ m_Com_Amazonaws_Dynamodb.Dummy__ 174 var _ m_KeyStore.Dummy__ 175 var _ m_AlgorithmSuites.Dummy__ 176 var _ m_Materials.Dummy__ 177 var _ m_Keyring.Dummy__ 178 var _ m_MultiKeyring.Dummy__ 179 var _ m_AwsKmsMrkAreUnique.Dummy__ 180 var _ m_Constants.Dummy__ 181 var _ m_MaterialWrapping.Dummy__ 182 var _ m_CanonicalEncryptionContext.Dummy__ 183 var _ m_IntermediateKeyWrapping.Dummy__ 184 var _ m_EdkWrapping.Dummy__ 185 var _ m_ErrorMessages.Dummy__ 186 var _ m_AwsKmsKeyring.Dummy__ 187 var _ m_StrictMultiKeyring.Dummy__ 188 var _ m_AwsKmsDiscoveryKeyring.Dummy__ 189 var _ m_DiscoveryMultiKeyring.Dummy__ 190 var _ m_AwsKmsMrkDiscoveryKeyring.Dummy__ 191 var _ m_MrkAwareDiscoveryMultiKeyring.Dummy__ 192 var _ m_AwsKmsMrkKeyring.Dummy__ 193 var _ m_MrkAwareStrictMultiKeyring.Dummy__ 194 var _ m_LocalCMC.Dummy__ 195 var _ m_SynchronizedLocalCMC.Dummy__ 196 var _ m_StormTracker.Dummy__ 197 var _ m_StormTrackingCMC.Dummy__ 198 var _ m_CacheConstants.Dummy__ 199 var _ m_AwsKmsHierarchicalKeyring.Dummy__ 200 var _ m_AwsKmsRsaKeyring.Dummy__ 201 var _ m_EcdhEdkWrapping.Dummy__ 202 var _ m_RawECDHKeyring.Dummy__ 203 var _ m_AwsKmsEcdhKeyring.Dummy__ 204 var _ m_RawAESKeyring.Dummy__ 205 206 type Dummy__ struct{} 207 208 // Definition of class RawRSAKeyring 209 type RawRSAKeyring struct { 210 _cryptoPrimitives *m_AtomicPrimitives.AtomicPrimitivesClient 211 _keyNamespace _dafny.Sequence 212 _keyName _dafny.Sequence 213 _paddingScheme m_AwsCryptographyPrimitivesTypes.RSAPaddingMode 214 _publicKey m_Wrappers.Option 215 _privateKey m_Wrappers.Option 216 } 217 218 func New_RawRSAKeyring_() *RawRSAKeyring { 219 _this := RawRSAKeyring{} 220 221 _this._cryptoPrimitives = (*m_AtomicPrimitives.AtomicPrimitivesClient)(nil) 222 _this._keyNamespace = m_UTF8.Companion_ValidUTF8Bytes_.Witness() 223 _this._keyName = m_UTF8.Companion_ValidUTF8Bytes_.Witness() 224 _this._paddingScheme = m_AwsCryptographyPrimitivesTypes.Companion_RSAPaddingMode_.Default() 225 _this._publicKey = m_Wrappers.Companion_Option_.Default() 226 _this._privateKey = m_Wrappers.Companion_Option_.Default() 227 return &_this 228 } 229 230 type CompanionStruct_RawRSAKeyring_ struct { 231 } 232 233 var Companion_RawRSAKeyring_ = CompanionStruct_RawRSAKeyring_{} 234 235 func (_this *RawRSAKeyring) Equals(other *RawRSAKeyring) bool { 236 return _this == other 237 } 238 239 func (_this *RawRSAKeyring) EqualsGeneric(x interface{}) bool { 240 other, ok := x.(*RawRSAKeyring) 241 return ok && _this.Equals(other) 242 } 243 244 func (*RawRSAKeyring) String() string { 245 return "RawRSAKeyring.RawRSAKeyring" 246 } 247 248 func Type_RawRSAKeyring_() _dafny.TypeDescriptor { 249 return type_RawRSAKeyring_{} 250 } 251 252 type type_RawRSAKeyring_ struct { 253 } 254 255 func (_this type_RawRSAKeyring_) Default() interface{} { 256 return (*RawRSAKeyring)(nil) 257 } 258 259 func (_this type_RawRSAKeyring_) String() string { 260 return "RawRSAKeyring.RawRSAKeyring" 261 } 262 func (_this *RawRSAKeyring) ParentTraits_() []*_dafny.TraitID { 263 return [](*_dafny.TraitID){m_Keyring.Companion_VerifiableInterface_.TraitID_, m_AwsCryptographyMaterialProvidersTypes.Companion_IKeyring_.TraitID_} 264 } 265 266 var _ m_Keyring.VerifiableInterface = &RawRSAKeyring{} 267 var _ m_AwsCryptographyMaterialProvidersTypes.IKeyring = &RawRSAKeyring{} 268 var _ _dafny.TraitOffspring = &RawRSAKeyring{} 269 270 func (_this *RawRSAKeyring) OnDecrypt(input m_AwsCryptographyMaterialProvidersTypes.OnDecryptInput) m_Wrappers.Result { 271 var _out11 m_Wrappers.Result 272 _ = _out11 273 _out11 = m_AwsCryptographyMaterialProvidersTypes.Companion_IKeyring_.OnDecrypt(_this, input) 274 return _out11 275 } 276 func (_this *RawRSAKeyring) OnEncrypt(input m_AwsCryptographyMaterialProvidersTypes.OnEncryptInput) m_Wrappers.Result { 277 var _out11 m_Wrappers.Result 278 _ = _out11 279 _out11 = m_AwsCryptographyMaterialProvidersTypes.Companion_IKeyring_.OnEncrypt(_this, input) 280 return _out11 281 } 282 func (_this *RawRSAKeyring) Ctor__(namespace _dafny.Sequence, name _dafny.Sequence, publicKey m_Wrappers.Option, privateKey m_Wrappers.Option, paddingScheme m_AwsCryptographyPrimitivesTypes.RSAPaddingMode, cryptoPrimitives *m_AtomicPrimitives.AtomicPrimitivesClient) { 283 { 284 (_this)._keyNamespace = namespace 285 (_this)._keyName = name 286 (_this)._paddingScheme = paddingScheme 287 (_this)._publicKey = publicKey 288 (_this)._privateKey = privateKey 289 (_this)._cryptoPrimitives = cryptoPrimitives 290 } 291 } 292 func (_this *RawRSAKeyring) OnEncrypt_k(input m_AwsCryptographyMaterialProvidersTypes.OnEncryptInput) m_Wrappers.Result { 293 { 294 var output m_Wrappers.Result = m_Wrappers.Result{} 295 _ = output 296 var _0_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 297 _ = _0_valueOrError0 298 _0_valueOrError0 = m_Wrappers.Companion_Default___.Need((((_this).PublicKey()).Is_Some()) && ((_dafny.IntOfUint32((((_this).PublicKey()).Extract().(_dafny.Sequence)).Cardinality())).Sign() == 1), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("A RawRSAKeyring without a public key cannot provide OnEncrypt"))) 299 if (_0_valueOrError0).IsFailure() { 300 output = (_0_valueOrError0).PropagateFailure() 301 return output 302 } 303 var _1_materials m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials 304 _ = _1_materials 305 _1_materials = (input).Dtor_materials() 306 var _2_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo 307 _ = _2_suite 308 _2_suite = (_1_materials).Dtor_algorithmSuite() 309 var _3_wrap *RsaWrapKeyMaterial 310 _ = _3_wrap 311 var _nw0 *RsaWrapKeyMaterial = New_RsaWrapKeyMaterial_() 312 _ = _nw0 313 _nw0.Ctor__(((_this).PublicKey()).Dtor_value().(_dafny.Sequence), (_this).PaddingScheme(), (_this).CryptoPrimitives()) 314 _3_wrap = _nw0 315 var _4_generateAndWrap *RsaGenerateAndWrapKeyMaterial 316 _ = _4_generateAndWrap 317 var _nw1 *RsaGenerateAndWrapKeyMaterial = New_RsaGenerateAndWrapKeyMaterial_() 318 _ = _nw1 319 _nw1.Ctor__(((_this).PublicKey()).Dtor_value().(_dafny.Sequence), (_this).PaddingScheme(), (_this).CryptoPrimitives()) 320 _4_generateAndWrap = _nw1 321 var _5_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_EdkWrapping.Companion_WrapEdkMaterialOutput_.Default(Companion_RsaWrapInfo_.Default())) 322 _ = _5_valueOrError1 323 var _out0 m_Wrappers.Result 324 _ = _out0 325 _out0 = m_EdkWrapping.Companion_Default___.WrapEdkMaterial(_1_materials, _3_wrap, _4_generateAndWrap) 326 _5_valueOrError1 = _out0 327 if (_5_valueOrError1).IsFailure() { 328 output = (_5_valueOrError1).PropagateFailure() 329 return output 330 } 331 var _6_wrapOutput m_EdkWrapping.WrapEdkMaterialOutput 332 _ = _6_wrapOutput 333 _6_wrapOutput = (_5_valueOrError1).Extract().(m_EdkWrapping.WrapEdkMaterialOutput) 334 var _7_symmetricSigningKeyList m_Wrappers.Option 335 _ = _7_symmetricSigningKeyList 336 if ((_6_wrapOutput).Dtor_symmetricSigningKey()).Is_Some() { 337 _7_symmetricSigningKeyList = m_Wrappers.Companion_Option_.Create_Some_(_dafny.SeqOf(((_6_wrapOutput).Dtor_symmetricSigningKey()).Dtor_value().(_dafny.Sequence))) 338 } else { 339 _7_symmetricSigningKeyList = m_Wrappers.Companion_Option_.Create_None_() 340 } 341 var _8_edk m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey 342 _ = _8_edk 343 _8_edk = m_AwsCryptographyMaterialProvidersTypes.Companion_EncryptedDataKey_.Create_EncryptedDataKey_((_this).KeyNamespace(), (_this).KeyName(), (_6_wrapOutput).Dtor_wrappedMaterial()) 344 if (_6_wrapOutput).Is_GenerateAndWrapEdkMaterialOutput() { 345 var _9_valueOrError2 m_Wrappers.Result = m_Wrappers.Result{} 346 _ = _9_valueOrError2 347 _9_valueOrError2 = m_Materials.Companion_Default___.EncryptionMaterialAddDataKey(_1_materials, (_6_wrapOutput).Dtor_plaintextDataKey(), _dafny.SeqOf(_8_edk), _7_symmetricSigningKeyList) 348 if (_9_valueOrError2).IsFailure() { 349 output = (_9_valueOrError2).PropagateFailure() 350 return output 351 } 352 var _10_result m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials 353 _ = _10_result 354 _10_result = (_9_valueOrError2).Extract().(m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials) 355 output = m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_OnEncryptOutput_.Create_OnEncryptOutput_(_10_result)) 356 return output 357 } else if (_6_wrapOutput).Is_WrapOnlyEdkMaterialOutput() { 358 var _11_valueOrError3 m_Wrappers.Result = m_Wrappers.Result{} 359 _ = _11_valueOrError3 360 _11_valueOrError3 = m_Materials.Companion_Default___.EncryptionMaterialAddEncryptedDataKeys(_1_materials, _dafny.SeqOf(_8_edk), _7_symmetricSigningKeyList) 361 if (_11_valueOrError3).IsFailure() { 362 output = (_11_valueOrError3).PropagateFailure() 363 return output 364 } 365 var _12_result m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials 366 _ = _12_result 367 _12_result = (_11_valueOrError3).Extract().(m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials) 368 output = m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_OnEncryptOutput_.Create_OnEncryptOutput_(_12_result)) 369 return output 370 } 371 return output 372 } 373 } 374 func (_this *RawRSAKeyring) OnDecrypt_k(input m_AwsCryptographyMaterialProvidersTypes.OnDecryptInput) m_Wrappers.Result { 375 { 376 var output m_Wrappers.Result = m_Wrappers.Result{} 377 _ = output 378 var _0_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 379 _ = _0_valueOrError0 380 _0_valueOrError0 = m_Wrappers.Companion_Default___.Need((((_this).PrivateKey()).Is_Some()) && ((_dafny.IntOfUint32((((_this).PrivateKey()).Extract().(_dafny.Sequence)).Cardinality())).Sign() == 1), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("A RawRSAKeyring without a private key cannot provide OnEncrypt"))) 381 if (_0_valueOrError0).IsFailure() { 382 output = (_0_valueOrError0).PropagateFailure() 383 return output 384 } 385 var _1_materials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials 386 _ = _1_materials 387 _1_materials = (input).Dtor_materials() 388 var _2_valueOrError1 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 389 _ = _2_valueOrError1 390 _2_valueOrError1 = m_Wrappers.Companion_Default___.Need(m_Materials.Companion_Default___.DecryptionMaterialsWithoutPlaintextDataKey(_1_materials), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Keyring received decryption materials that already contain a plaintext data key."))) 391 if (_2_valueOrError1).IsFailure() { 392 output = (_2_valueOrError1).PropagateFailure() 393 return output 394 } 395 var _3_errors _dafny.Sequence 396 _ = _3_errors 397 _3_errors = _dafny.SeqOf() 398 var _hi0 _dafny.Int = _dafny.IntOfUint32(((input).Dtor_encryptedDataKeys()).Cardinality()) 399 _ = _hi0 400 for _4_i := _dafny.Zero; _4_i.Cmp(_hi0) < 0; _4_i = _4_i.Plus(_dafny.One) { 401 if (_this).ShouldDecryptEDK(((input).Dtor_encryptedDataKeys()).Select((_4_i).Uint32()).(m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey)) { 402 var _5_edk m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey 403 _ = _5_edk 404 _5_edk = ((input).Dtor_encryptedDataKeys()).Select((_4_i).Uint32()).(m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey) 405 var _6_unwrap *RsaUnwrapKeyMaterial 406 _ = _6_unwrap 407 var _nw0 *RsaUnwrapKeyMaterial = New_RsaUnwrapKeyMaterial_() 408 _ = _nw0 409 _nw0.Ctor__(((_this).PrivateKey()).Extract().(_dafny.Sequence), (_this).PaddingScheme(), (_this).CryptoPrimitives()) 410 _6_unwrap = _nw0 411 var _7_unwrapOutput m_Wrappers.Result 412 _ = _7_unwrapOutput 413 var _out0 m_Wrappers.Result 414 _ = _out0 415 _out0 = m_EdkWrapping.Companion_Default___.UnwrapEdkMaterial((_5_edk).Dtor_ciphertext(), _1_materials, _6_unwrap) 416 _7_unwrapOutput = _out0 417 if (_7_unwrapOutput).Is_Success() { 418 var _8_valueOrError2 m_Wrappers.Result = m_Wrappers.Result{} 419 _ = _8_valueOrError2 420 _8_valueOrError2 = m_Materials.Companion_Default___.DecryptionMaterialsAddDataKey(_1_materials, ((_7_unwrapOutput).Dtor_value().(m_EdkWrapping.UnwrapEdkMaterialOutput)).Dtor_plaintextDataKey(), ((_7_unwrapOutput).Dtor_value().(m_EdkWrapping.UnwrapEdkMaterialOutput)).Dtor_symmetricSigningKey()) 421 if (_8_valueOrError2).IsFailure() { 422 output = (_8_valueOrError2).PropagateFailure() 423 return output 424 } 425 var _9_returnMaterials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials 426 _ = _9_returnMaterials 427 _9_returnMaterials = (_8_valueOrError2).Extract().(m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials) 428 output = m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_OnDecryptOutput_.Create_OnDecryptOutput_(_9_returnMaterials)) 429 return output 430 } else { 431 _3_errors = _dafny.Companion_Sequence_.Concatenate(_3_errors, _dafny.SeqOf((_7_unwrapOutput).Dtor_error().(m_AwsCryptographyMaterialProvidersTypes.Error))) 432 } 433 } else { 434 var _10_valueOrError3 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq.SetString()) 435 _ = _10_valueOrError3 436 _10_valueOrError3 = (m_UTF8.Decode((((input).Dtor_encryptedDataKeys()).Select((_4_i).Uint32()).(m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey)).Dtor_keyProviderId())).MapFailure(func(coer125 func(_dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 437 return func(arg126 interface{}) interface{} { 438 return coer125(arg126.(_dafny.Sequence)) 439 } 440 }(func(_11_e _dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error { 441 return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_11_e) 442 })) 443 if (_10_valueOrError3).IsFailure() { 444 output = (_10_valueOrError3).PropagateFailure() 445 return output 446 } 447 var _12_extractedKeyProviderId _dafny.Sequence 448 _ = _12_extractedKeyProviderId 449 _12_extractedKeyProviderId = (_10_valueOrError3).Extract().(_dafny.Sequence) 450 _3_errors = _dafny.Companion_Sequence_.Concatenate(_3_errors, _dafny.SeqOf(m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(m_ErrorMessages.Companion_Default___.IncorrectRawDataKeys(m_StandardLibrary_String.Companion_Default___.Base10Int2String(_4_i), _dafny.SeqOfString("RSAKeyring"), _12_extractedKeyProviderId)))) 451 } 452 } 453 output = m_Wrappers.Companion_Result_.Create_Failure_(m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_CollectionOfErrors_(_3_errors, _dafny.SeqOfString("Raw RSA Key was unable to decrypt any encrypted data key. The list of encountered Exceptions is avaible via `list`."))) 454 return output 455 return output 456 } 457 } 458 func (_this *RawRSAKeyring) ShouldDecryptEDK(edk m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey) bool { 459 { 460 return (((m_UTF8.Companion_Default___.ValidUTF8Seq((edk).Dtor_keyProviderInfo())) && (_dafny.Companion_Sequence_.Equal((edk).Dtor_keyProviderInfo(), (_this).KeyName()))) && (_dafny.Companion_Sequence_.Equal((edk).Dtor_keyProviderId(), (_this).KeyNamespace()))) && ((_dafny.IntOfUint32(((edk).Dtor_ciphertext()).Cardinality())).Sign() == 1) 461 } 462 } 463 func (_this *RawRSAKeyring) CryptoPrimitives() *m_AtomicPrimitives.AtomicPrimitivesClient { 464 { 465 return _this._cryptoPrimitives 466 } 467 } 468 func (_this *RawRSAKeyring) KeyNamespace() _dafny.Sequence { 469 { 470 return _this._keyNamespace 471 } 472 } 473 func (_this *RawRSAKeyring) KeyName() _dafny.Sequence { 474 { 475 return _this._keyName 476 } 477 } 478 func (_this *RawRSAKeyring) PaddingScheme() m_AwsCryptographyPrimitivesTypes.RSAPaddingMode { 479 { 480 return _this._paddingScheme 481 } 482 } 483 func (_this *RawRSAKeyring) PublicKey() m_Wrappers.Option { 484 { 485 return _this._publicKey 486 } 487 } 488 func (_this *RawRSAKeyring) PrivateKey() m_Wrappers.Option { 489 { 490 return _this._privateKey 491 } 492 } 493 494 // End of class RawRSAKeyring 495 496 // Definition of datatype RsaUnwrapInfo 497 type RsaUnwrapInfo struct { 498 Data_RsaUnwrapInfo_ 499 } 500 501 func (_this RsaUnwrapInfo) Get_() Data_RsaUnwrapInfo_ { 502 return _this.Data_RsaUnwrapInfo_ 503 } 504 505 type Data_RsaUnwrapInfo_ interface { 506 isRsaUnwrapInfo() 507 } 508 509 type CompanionStruct_RsaUnwrapInfo_ struct { 510 } 511 512 var Companion_RsaUnwrapInfo_ = CompanionStruct_RsaUnwrapInfo_{} 513 514 type RsaUnwrapInfo_RsaUnwrapInfo struct { 515 } 516 517 func (RsaUnwrapInfo_RsaUnwrapInfo) isRsaUnwrapInfo() {} 518 519 func (CompanionStruct_RsaUnwrapInfo_) Create_RsaUnwrapInfo_() RsaUnwrapInfo { 520 return RsaUnwrapInfo{RsaUnwrapInfo_RsaUnwrapInfo{}} 521 } 522 523 func (_this RsaUnwrapInfo) Is_RsaUnwrapInfo() bool { 524 _, ok := _this.Get_().(RsaUnwrapInfo_RsaUnwrapInfo) 525 return ok 526 } 527 528 func (CompanionStruct_RsaUnwrapInfo_) Default() RsaUnwrapInfo { 529 return Companion_RsaUnwrapInfo_.Create_RsaUnwrapInfo_() 530 } 531 532 func (_ CompanionStruct_RsaUnwrapInfo_) AllSingletonConstructors() _dafny.Iterator { 533 i := -1 534 return func() (interface{}, bool) { 535 i++ 536 switch i { 537 case 0: 538 return Companion_RsaUnwrapInfo_.Create_RsaUnwrapInfo_(), true 539 default: 540 return RsaUnwrapInfo{}, false 541 } 542 } 543 } 544 545 func (_this RsaUnwrapInfo) String() string { 546 switch _this.Get_().(type) { 547 case nil: 548 return "null" 549 case RsaUnwrapInfo_RsaUnwrapInfo: 550 { 551 return "RawRSAKeyring.RsaUnwrapInfo.RsaUnwrapInfo" 552 } 553 default: 554 { 555 return "<unexpected>" 556 } 557 } 558 } 559 560 func (_this RsaUnwrapInfo) Equals(other RsaUnwrapInfo) bool { 561 switch _this.Get_().(type) { 562 case RsaUnwrapInfo_RsaUnwrapInfo: 563 { 564 _, ok := other.Get_().(RsaUnwrapInfo_RsaUnwrapInfo) 565 return ok 566 } 567 default: 568 { 569 return false // unexpected 570 } 571 } 572 } 573 574 func (_this RsaUnwrapInfo) EqualsGeneric(other interface{}) bool { 575 typed, ok := other.(RsaUnwrapInfo) 576 return ok && _this.Equals(typed) 577 } 578 579 func Type_RsaUnwrapInfo_() _dafny.TypeDescriptor { 580 return type_RsaUnwrapInfo_{} 581 } 582 583 type type_RsaUnwrapInfo_ struct { 584 } 585 586 func (_this type_RsaUnwrapInfo_) Default() interface{} { 587 return Companion_RsaUnwrapInfo_.Default() 588 } 589 590 func (_this type_RsaUnwrapInfo_) String() string { 591 return "RawRSAKeyring.RsaUnwrapInfo" 592 } 593 func (_this RsaUnwrapInfo) ParentTraits_() []*_dafny.TraitID { 594 return [](*_dafny.TraitID){} 595 } 596 597 var _ _dafny.TraitOffspring = RsaUnwrapInfo{} 598 599 // End of datatype RsaUnwrapInfo 600 601 // Definition of datatype RsaWrapInfo 602 type RsaWrapInfo struct { 603 Data_RsaWrapInfo_ 604 } 605 606 func (_this RsaWrapInfo) Get_() Data_RsaWrapInfo_ { 607 return _this.Data_RsaWrapInfo_ 608 } 609 610 type Data_RsaWrapInfo_ interface { 611 isRsaWrapInfo() 612 } 613 614 type CompanionStruct_RsaWrapInfo_ struct { 615 } 616 617 var Companion_RsaWrapInfo_ = CompanionStruct_RsaWrapInfo_{} 618 619 type RsaWrapInfo_RsaWrapInfo struct { 620 } 621 622 func (RsaWrapInfo_RsaWrapInfo) isRsaWrapInfo() {} 623 624 func (CompanionStruct_RsaWrapInfo_) Create_RsaWrapInfo_() RsaWrapInfo { 625 return RsaWrapInfo{RsaWrapInfo_RsaWrapInfo{}} 626 } 627 628 func (_this RsaWrapInfo) Is_RsaWrapInfo() bool { 629 _, ok := _this.Get_().(RsaWrapInfo_RsaWrapInfo) 630 return ok 631 } 632 633 func (CompanionStruct_RsaWrapInfo_) Default() RsaWrapInfo { 634 return Companion_RsaWrapInfo_.Create_RsaWrapInfo_() 635 } 636 637 func (_ CompanionStruct_RsaWrapInfo_) AllSingletonConstructors() _dafny.Iterator { 638 i := -1 639 return func() (interface{}, bool) { 640 i++ 641 switch i { 642 case 0: 643 return Companion_RsaWrapInfo_.Create_RsaWrapInfo_(), true 644 default: 645 return RsaWrapInfo{}, false 646 } 647 } 648 } 649 650 func (_this RsaWrapInfo) String() string { 651 switch _this.Get_().(type) { 652 case nil: 653 return "null" 654 case RsaWrapInfo_RsaWrapInfo: 655 { 656 return "RawRSAKeyring.RsaWrapInfo.RsaWrapInfo" 657 } 658 default: 659 { 660 return "<unexpected>" 661 } 662 } 663 } 664 665 func (_this RsaWrapInfo) Equals(other RsaWrapInfo) bool { 666 switch _this.Get_().(type) { 667 case RsaWrapInfo_RsaWrapInfo: 668 { 669 _, ok := other.Get_().(RsaWrapInfo_RsaWrapInfo) 670 return ok 671 } 672 default: 673 { 674 return false // unexpected 675 } 676 } 677 } 678 679 func (_this RsaWrapInfo) EqualsGeneric(other interface{}) bool { 680 typed, ok := other.(RsaWrapInfo) 681 return ok && _this.Equals(typed) 682 } 683 684 func Type_RsaWrapInfo_() _dafny.TypeDescriptor { 685 return type_RsaWrapInfo_{} 686 } 687 688 type type_RsaWrapInfo_ struct { 689 } 690 691 func (_this type_RsaWrapInfo_) Default() interface{} { 692 return Companion_RsaWrapInfo_.Default() 693 } 694 695 func (_this type_RsaWrapInfo_) String() string { 696 return "RawRSAKeyring.RsaWrapInfo" 697 } 698 func (_this RsaWrapInfo) ParentTraits_() []*_dafny.TraitID { 699 return [](*_dafny.TraitID){} 700 } 701 702 var _ _dafny.TraitOffspring = RsaWrapInfo{} 703 704 // End of datatype RsaWrapInfo 705 706 // Definition of class RsaGenerateAndWrapKeyMaterial 707 type RsaGenerateAndWrapKeyMaterial struct { 708 _publicKey _dafny.Sequence 709 _paddingScheme m_AwsCryptographyPrimitivesTypes.RSAPaddingMode 710 _cryptoPrimitives *m_AtomicPrimitives.AtomicPrimitivesClient 711 } 712 713 func New_RsaGenerateAndWrapKeyMaterial_() *RsaGenerateAndWrapKeyMaterial { 714 _this := RsaGenerateAndWrapKeyMaterial{} 715 716 _this._publicKey = _dafny.EmptySeq 717 _this._paddingScheme = m_AwsCryptographyPrimitivesTypes.Companion_RSAPaddingMode_.Default() 718 _this._cryptoPrimitives = (*m_AtomicPrimitives.AtomicPrimitivesClient)(nil) 719 return &_this 720 } 721 722 type CompanionStruct_RsaGenerateAndWrapKeyMaterial_ struct { 723 } 724 725 var Companion_RsaGenerateAndWrapKeyMaterial_ = CompanionStruct_RsaGenerateAndWrapKeyMaterial_{} 726 727 func (_this *RsaGenerateAndWrapKeyMaterial) Equals(other *RsaGenerateAndWrapKeyMaterial) bool { 728 return _this == other 729 } 730 731 func (_this *RsaGenerateAndWrapKeyMaterial) EqualsGeneric(x interface{}) bool { 732 other, ok := x.(*RsaGenerateAndWrapKeyMaterial) 733 return ok && _this.Equals(other) 734 } 735 736 func (*RsaGenerateAndWrapKeyMaterial) String() string { 737 return "RawRSAKeyring.RsaGenerateAndWrapKeyMaterial" 738 } 739 740 func Type_RsaGenerateAndWrapKeyMaterial_() _dafny.TypeDescriptor { 741 return type_RsaGenerateAndWrapKeyMaterial_{} 742 } 743 744 type type_RsaGenerateAndWrapKeyMaterial_ struct { 745 } 746 747 func (_this type_RsaGenerateAndWrapKeyMaterial_) Default() interface{} { 748 return (*RsaGenerateAndWrapKeyMaterial)(nil) 749 } 750 751 func (_this type_RsaGenerateAndWrapKeyMaterial_) String() string { 752 return "RawRSAKeyring.RsaGenerateAndWrapKeyMaterial" 753 } 754 func (_this *RsaGenerateAndWrapKeyMaterial) ParentTraits_() []*_dafny.TraitID { 755 return [](*_dafny.TraitID){m_MaterialWrapping.Companion_GenerateAndWrapMaterial_.TraitID_, m_Actions.Companion_ActionWithResult_.TraitID_, m_Actions.Companion_Action_.TraitID_} 756 } 757 758 var _ m_MaterialWrapping.GenerateAndWrapMaterial = &RsaGenerateAndWrapKeyMaterial{} 759 var _ m_Actions.ActionWithResult = &RsaGenerateAndWrapKeyMaterial{} 760 var _ m_Actions.Action = &RsaGenerateAndWrapKeyMaterial{} 761 var _ _dafny.TraitOffspring = &RsaGenerateAndWrapKeyMaterial{} 762 763 func (_this *RsaGenerateAndWrapKeyMaterial) Ctor__(publicKey _dafny.Sequence, paddingScheme m_AwsCryptographyPrimitivesTypes.RSAPaddingMode, cryptoPrimitives *m_AtomicPrimitives.AtomicPrimitivesClient) { 764 { 765 (_this)._publicKey = publicKey 766 (_this)._paddingScheme = paddingScheme 767 (_this)._cryptoPrimitives = cryptoPrimitives 768 } 769 } 770 func (_this *RsaGenerateAndWrapKeyMaterial) Invoke(input interface{}) interface{} { 771 { 772 var input m_MaterialWrapping.GenerateAndWrapInput = input.(m_MaterialWrapping.GenerateAndWrapInput) 773 _ = input 774 var res m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_MaterialWrapping.Companion_GenerateAndWrapOutput_.Default(Companion_RsaWrapInfo_.Default())) 775 _ = res 776 var _0_generateBytesResult m_Wrappers.Result 777 _ = _0_generateBytesResult 778 var _out0 m_Wrappers.Result 779 _ = _out0 780 _out0 = ((_this).CryptoPrimitives()).GenerateRandomBytes(m_AwsCryptographyPrimitivesTypes.Companion_GenerateRandomBytesInput_.Create_GenerateRandomBytesInput_(m_AlgorithmSuites.Companion_Default___.GetEncryptKeyLength((input).Dtor_algorithmSuite()))) 781 _0_generateBytesResult = _out0 782 var _1_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq) 783 _ = _1_valueOrError0 784 _1_valueOrError0 = (_0_generateBytesResult).MapFailure(func(coer126 func(m_AwsCryptographyPrimitivesTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 785 return func(arg127 interface{}) interface{} { 786 return coer126(arg127.(m_AwsCryptographyPrimitivesTypes.Error)) 787 } 788 }(func(_2_e m_AwsCryptographyPrimitivesTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error { 789 return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographyPrimitives_(_2_e) 790 })) 791 if (_1_valueOrError0).IsFailure() { 792 res = (_1_valueOrError0).PropagateFailure() 793 return res 794 } 795 var _3_plaintextMaterial _dafny.Sequence 796 _ = _3_plaintextMaterial 797 _3_plaintextMaterial = (_1_valueOrError0).Extract().(_dafny.Sequence) 798 var _4_wrap *RsaWrapKeyMaterial 799 _ = _4_wrap 800 var _nw0 *RsaWrapKeyMaterial = New_RsaWrapKeyMaterial_() 801 _ = _nw0 802 _nw0.Ctor__((_this).PublicKey(), (_this).PaddingScheme(), (_this).CryptoPrimitives()) 803 _4_wrap = _nw0 804 var _5_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_MaterialWrapping.Companion_WrapOutput_.Default(Companion_RsaWrapInfo_.Default())) 805 _ = _5_valueOrError1 806 var _out1 interface{} 807 _ = _out1 808 _out1 = (_4_wrap).Invoke(m_MaterialWrapping.Companion_WrapInput_.Create_WrapInput_(_3_plaintextMaterial, (input).Dtor_algorithmSuite(), (input).Dtor_encryptionContext())) 809 _5_valueOrError1 = _out1.(m_Wrappers.Result) 810 if (_5_valueOrError1).IsFailure() { 811 res = (_5_valueOrError1).PropagateFailure() 812 return res 813 } 814 var _6_wrapOutput m_MaterialWrapping.WrapOutput 815 _ = _6_wrapOutput 816 _6_wrapOutput = (_5_valueOrError1).Extract().(m_MaterialWrapping.WrapOutput) 817 var _7_output m_MaterialWrapping.GenerateAndWrapOutput 818 _ = _7_output 819 _7_output = m_MaterialWrapping.Companion_GenerateAndWrapOutput_.Create_GenerateAndWrapOutput_(_3_plaintextMaterial, (_6_wrapOutput).Dtor_wrappedMaterial(), Companion_RsaWrapInfo_.Create_RsaWrapInfo_()) 820 res = m_Wrappers.Companion_Result_.Create_Success_(_7_output) 821 return res 822 return res 823 } 824 } 825 func (_this *RsaGenerateAndWrapKeyMaterial) PublicKey() _dafny.Sequence { 826 { 827 return _this._publicKey 828 } 829 } 830 func (_this *RsaGenerateAndWrapKeyMaterial) PaddingScheme() m_AwsCryptographyPrimitivesTypes.RSAPaddingMode { 831 { 832 return _this._paddingScheme 833 } 834 } 835 func (_this *RsaGenerateAndWrapKeyMaterial) CryptoPrimitives() *m_AtomicPrimitives.AtomicPrimitivesClient { 836 { 837 return _this._cryptoPrimitives 838 } 839 } 840 841 // End of class RsaGenerateAndWrapKeyMaterial 842 843 // Definition of class RsaWrapKeyMaterial 844 type RsaWrapKeyMaterial struct { 845 _publicKey _dafny.Sequence 846 _paddingScheme m_AwsCryptographyPrimitivesTypes.RSAPaddingMode 847 _cryptoPrimitives *m_AtomicPrimitives.AtomicPrimitivesClient 848 } 849 850 func New_RsaWrapKeyMaterial_() *RsaWrapKeyMaterial { 851 _this := RsaWrapKeyMaterial{} 852 853 _this._publicKey = _dafny.EmptySeq 854 _this._paddingScheme = m_AwsCryptographyPrimitivesTypes.Companion_RSAPaddingMode_.Default() 855 _this._cryptoPrimitives = (*m_AtomicPrimitives.AtomicPrimitivesClient)(nil) 856 return &_this 857 } 858 859 type CompanionStruct_RsaWrapKeyMaterial_ struct { 860 } 861 862 var Companion_RsaWrapKeyMaterial_ = CompanionStruct_RsaWrapKeyMaterial_{} 863 864 func (_this *RsaWrapKeyMaterial) Equals(other *RsaWrapKeyMaterial) bool { 865 return _this == other 866 } 867 868 func (_this *RsaWrapKeyMaterial) EqualsGeneric(x interface{}) bool { 869 other, ok := x.(*RsaWrapKeyMaterial) 870 return ok && _this.Equals(other) 871 } 872 873 func (*RsaWrapKeyMaterial) String() string { 874 return "RawRSAKeyring.RsaWrapKeyMaterial" 875 } 876 877 func Type_RsaWrapKeyMaterial_() _dafny.TypeDescriptor { 878 return type_RsaWrapKeyMaterial_{} 879 } 880 881 type type_RsaWrapKeyMaterial_ struct { 882 } 883 884 func (_this type_RsaWrapKeyMaterial_) Default() interface{} { 885 return (*RsaWrapKeyMaterial)(nil) 886 } 887 888 func (_this type_RsaWrapKeyMaterial_) String() string { 889 return "RawRSAKeyring.RsaWrapKeyMaterial" 890 } 891 func (_this *RsaWrapKeyMaterial) ParentTraits_() []*_dafny.TraitID { 892 return [](*_dafny.TraitID){m_MaterialWrapping.Companion_WrapMaterial_.TraitID_, m_Actions.Companion_ActionWithResult_.TraitID_, m_Actions.Companion_Action_.TraitID_} 893 } 894 895 var _ m_MaterialWrapping.WrapMaterial = &RsaWrapKeyMaterial{} 896 var _ m_Actions.ActionWithResult = &RsaWrapKeyMaterial{} 897 var _ m_Actions.Action = &RsaWrapKeyMaterial{} 898 var _ _dafny.TraitOffspring = &RsaWrapKeyMaterial{} 899 900 func (_this *RsaWrapKeyMaterial) Ctor__(publicKey _dafny.Sequence, paddingScheme m_AwsCryptographyPrimitivesTypes.RSAPaddingMode, cryptoPrimitives *m_AtomicPrimitives.AtomicPrimitivesClient) { 901 { 902 (_this)._publicKey = publicKey 903 (_this)._paddingScheme = paddingScheme 904 (_this)._cryptoPrimitives = cryptoPrimitives 905 } 906 } 907 func (_this *RsaWrapKeyMaterial) Invoke(input interface{}) interface{} { 908 { 909 var input m_MaterialWrapping.WrapInput = input.(m_MaterialWrapping.WrapInput) 910 _ = input 911 var res m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_MaterialWrapping.Companion_WrapOutput_.Default(Companion_RsaWrapInfo_.Default())) 912 _ = res 913 var _0_RSAEncryptOutput m_Wrappers.Result 914 _ = _0_RSAEncryptOutput 915 var _out0 m_Wrappers.Result 916 _ = _out0 917 _out0 = ((_this).CryptoPrimitives()).RSAEncrypt(m_AwsCryptographyPrimitivesTypes.Companion_RSAEncryptInput_.Create_RSAEncryptInput_((_this).PaddingScheme(), (_this).PublicKey(), (input).Dtor_plaintextMaterial())) 918 _0_RSAEncryptOutput = _out0 919 var _1_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq) 920 _ = _1_valueOrError0 921 _1_valueOrError0 = (_0_RSAEncryptOutput).MapFailure(func(coer127 func(m_AwsCryptographyPrimitivesTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 922 return func(arg128 interface{}) interface{} { 923 return coer127(arg128.(m_AwsCryptographyPrimitivesTypes.Error)) 924 } 925 }(func(_2_e m_AwsCryptographyPrimitivesTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error { 926 return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographyPrimitives_(_2_e) 927 })) 928 if (_1_valueOrError0).IsFailure() { 929 res = (_1_valueOrError0).PropagateFailure() 930 return res 931 } 932 var _3_ciphertext _dafny.Sequence 933 _ = _3_ciphertext 934 _3_ciphertext = (_1_valueOrError0).Extract().(_dafny.Sequence) 935 var _4_output m_MaterialWrapping.WrapOutput 936 _ = _4_output 937 _4_output = m_MaterialWrapping.Companion_WrapOutput_.Create_WrapOutput_(_3_ciphertext, Companion_RsaWrapInfo_.Create_RsaWrapInfo_()) 938 res = m_Wrappers.Companion_Result_.Create_Success_(_4_output) 939 return res 940 return res 941 } 942 } 943 func (_this *RsaWrapKeyMaterial) PublicKey() _dafny.Sequence { 944 { 945 return _this._publicKey 946 } 947 } 948 func (_this *RsaWrapKeyMaterial) PaddingScheme() m_AwsCryptographyPrimitivesTypes.RSAPaddingMode { 949 { 950 return _this._paddingScheme 951 } 952 } 953 func (_this *RsaWrapKeyMaterial) CryptoPrimitives() *m_AtomicPrimitives.AtomicPrimitivesClient { 954 { 955 return _this._cryptoPrimitives 956 } 957 } 958 959 // End of class RsaWrapKeyMaterial 960 961 // Definition of class RsaUnwrapKeyMaterial 962 type RsaUnwrapKeyMaterial struct { 963 _privateKey _dafny.Sequence 964 _paddingScheme m_AwsCryptographyPrimitivesTypes.RSAPaddingMode 965 _cryptoPrimitives *m_AtomicPrimitives.AtomicPrimitivesClient 966 } 967 968 func New_RsaUnwrapKeyMaterial_() *RsaUnwrapKeyMaterial { 969 _this := RsaUnwrapKeyMaterial{} 970 971 _this._privateKey = _dafny.EmptySeq 972 _this._paddingScheme = m_AwsCryptographyPrimitivesTypes.Companion_RSAPaddingMode_.Default() 973 _this._cryptoPrimitives = (*m_AtomicPrimitives.AtomicPrimitivesClient)(nil) 974 return &_this 975 } 976 977 type CompanionStruct_RsaUnwrapKeyMaterial_ struct { 978 } 979 980 var Companion_RsaUnwrapKeyMaterial_ = CompanionStruct_RsaUnwrapKeyMaterial_{} 981 982 func (_this *RsaUnwrapKeyMaterial) Equals(other *RsaUnwrapKeyMaterial) bool { 983 return _this == other 984 } 985 986 func (_this *RsaUnwrapKeyMaterial) EqualsGeneric(x interface{}) bool { 987 other, ok := x.(*RsaUnwrapKeyMaterial) 988 return ok && _this.Equals(other) 989 } 990 991 func (*RsaUnwrapKeyMaterial) String() string { 992 return "RawRSAKeyring.RsaUnwrapKeyMaterial" 993 } 994 995 func Type_RsaUnwrapKeyMaterial_() _dafny.TypeDescriptor { 996 return type_RsaUnwrapKeyMaterial_{} 997 } 998 999 type type_RsaUnwrapKeyMaterial_ struct { 1000 } 1001 1002 func (_this type_RsaUnwrapKeyMaterial_) Default() interface{} { 1003 return (*RsaUnwrapKeyMaterial)(nil) 1004 } 1005 1006 func (_this type_RsaUnwrapKeyMaterial_) String() string { 1007 return "RawRSAKeyring.RsaUnwrapKeyMaterial" 1008 } 1009 func (_this *RsaUnwrapKeyMaterial) ParentTraits_() []*_dafny.TraitID { 1010 return [](*_dafny.TraitID){m_MaterialWrapping.Companion_UnwrapMaterial_.TraitID_, m_Actions.Companion_ActionWithResult_.TraitID_, m_Actions.Companion_Action_.TraitID_} 1011 } 1012 1013 var _ m_MaterialWrapping.UnwrapMaterial = &RsaUnwrapKeyMaterial{} 1014 var _ m_Actions.ActionWithResult = &RsaUnwrapKeyMaterial{} 1015 var _ m_Actions.Action = &RsaUnwrapKeyMaterial{} 1016 var _ _dafny.TraitOffspring = &RsaUnwrapKeyMaterial{} 1017 1018 func (_this *RsaUnwrapKeyMaterial) Ctor__(privateKey _dafny.Sequence, paddingScheme m_AwsCryptographyPrimitivesTypes.RSAPaddingMode, cryptoPrimitives *m_AtomicPrimitives.AtomicPrimitivesClient) { 1019 { 1020 (_this)._privateKey = privateKey 1021 (_this)._paddingScheme = paddingScheme 1022 (_this)._cryptoPrimitives = cryptoPrimitives 1023 } 1024 } 1025 func (_this *RsaUnwrapKeyMaterial) Invoke(input interface{}) interface{} { 1026 { 1027 var input m_MaterialWrapping.UnwrapInput = input.(m_MaterialWrapping.UnwrapInput) 1028 _ = input 1029 var res m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_MaterialWrapping.Companion_UnwrapOutput_.Default(Companion_RsaUnwrapInfo_.Default())) 1030 _ = res 1031 var _0_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo 1032 _ = _0_suite 1033 _0_suite = (input).Dtor_algorithmSuite() 1034 var _1_wrappedMaterial _dafny.Sequence 1035 _ = _1_wrappedMaterial 1036 _1_wrappedMaterial = (input).Dtor_wrappedMaterial() 1037 var _2_aad _dafny.Map 1038 _ = _2_aad 1039 _2_aad = (input).Dtor_encryptionContext() 1040 var _3_maybeDecryptResult m_Wrappers.Result 1041 _ = _3_maybeDecryptResult 1042 var _out0 m_Wrappers.Result 1043 _ = _out0 1044 _out0 = ((_this).CryptoPrimitives()).RSADecrypt(m_AwsCryptographyPrimitivesTypes.Companion_RSADecryptInput_.Create_RSADecryptInput_((_this).PaddingScheme(), (_this).PrivateKey(), _1_wrappedMaterial)) 1045 _3_maybeDecryptResult = _out0 1046 var _4_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq) 1047 _ = _4_valueOrError0 1048 _4_valueOrError0 = (_3_maybeDecryptResult).MapFailure(func(coer128 func(m_AwsCryptographyPrimitivesTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 1049 return func(arg129 interface{}) interface{} { 1050 return coer128(arg129.(m_AwsCryptographyPrimitivesTypes.Error)) 1051 } 1052 }(func(_5_e m_AwsCryptographyPrimitivesTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error { 1053 return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographyPrimitives_(_5_e) 1054 })) 1055 if (_4_valueOrError0).IsFailure() { 1056 res = (_4_valueOrError0).PropagateFailure() 1057 return res 1058 } 1059 var _6_decryptResult _dafny.Sequence 1060 _ = _6_decryptResult 1061 _6_decryptResult = (_4_valueOrError0).Extract().(_dafny.Sequence) 1062 var _7_valueOrError1 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 1063 _ = _7_valueOrError1 1064 _7_valueOrError1 = m_Wrappers.Companion_Default___.Need((_dafny.IntOfUint32((_6_decryptResult).Cardinality())).Cmp(_dafny.IntOfInt32(m_AlgorithmSuites.Companion_Default___.GetEncryptKeyLength(_0_suite))) == 0, m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid plaintext length."))) 1065 if (_7_valueOrError1).IsFailure() { 1066 res = (_7_valueOrError1).PropagateFailure() 1067 return res 1068 } 1069 var _8_output m_MaterialWrapping.UnwrapOutput 1070 _ = _8_output 1071 _8_output = m_MaterialWrapping.Companion_UnwrapOutput_.Create_UnwrapOutput_(_6_decryptResult, Companion_RsaUnwrapInfo_.Create_RsaUnwrapInfo_()) 1072 res = m_Wrappers.Companion_Result_.Create_Success_(_8_output) 1073 return res 1074 return res 1075 } 1076 } 1077 func (_this *RsaUnwrapKeyMaterial) PrivateKey() _dafny.Sequence { 1078 { 1079 return _this._privateKey 1080 } 1081 } 1082 func (_this *RsaUnwrapKeyMaterial) PaddingScheme() m_AwsCryptographyPrimitivesTypes.RSAPaddingMode { 1083 { 1084 return _this._paddingScheme 1085 } 1086 } 1087 func (_this *RsaUnwrapKeyMaterial) CryptoPrimitives() *m_AtomicPrimitives.AtomicPrimitivesClient { 1088 { 1089 return _this._cryptoPrimitives 1090 } 1091 } 1092 1093 // End of class RsaUnwrapKeyMaterial