All Downloads are FREE. Search and download functionalities are using the official Maven repository.

AwsKmsHierarchicalKeyring_Compile.KmsHierarchyWrapKeyMaterial Maven / Gradle / Ivy

// Class KmsHierarchyWrapKeyMaterial
// Dafny class KmsHierarchyWrapKeyMaterial compiled into Java
package AwsKmsHierarchicalKeyring_Compile;

import software.amazon.cryptography.keystore.internaldafny.types.*;
import software.amazon.cryptography.materialproviders.internaldafny.types.*;
import AwsArnParsing_Compile.*;
import AwsKmsMrkMatchForDecrypt_Compile.*;
import AwsKmsUtils_Compile.*;
import KeyStoreErrorMessages_Compile.*;
import KmsArn_Compile.*;
import Structure_Compile.*;
import KMSKeystoreOperations_Compile.*;
import DDBKeystoreOperations_Compile.*;
import CreateKeys_Compile.*;
import CreateKeyStoreTable_Compile.*;
import GetKeys_Compile.*;
import AwsCryptographyKeyStoreOperations_Compile.*;
import software.amazon.cryptography.keystore.internaldafny.*;
import AlgorithmSuites_Compile.*;
import Materials_Compile.*;
import Keyring_Compile.*;
import MultiKeyring_Compile.*;
import AwsKmsMrkAreUnique_Compile.*;
import Constants_Compile.*;
import MaterialWrapping_Compile.*;
import CanonicalEncryptionContext_Compile.*;
import IntermediateKeyWrapping_Compile.*;
import EdkWrapping_Compile.*;
import ErrorMessages_Compile.*;
import AwsKmsKeyring_Compile.*;
import StrictMultiKeyring_Compile.*;
import AwsKmsDiscoveryKeyring_Compile.*;
import DiscoveryMultiKeyring_Compile.*;
import AwsKmsMrkDiscoveryKeyring_Compile.*;
import MrkAwareDiscoveryMultiKeyring_Compile.*;
import AwsKmsMrkKeyring_Compile.*;
import MrkAwareStrictMultiKeyring_Compile.*;
import LocalCMC_Compile.*;
import StormTracker_Compile.*;
import software.amazon.cryptography.internaldafny.StormTrackingCMC.*;
import CacheConstants_Compile.*;

@SuppressWarnings({"unchecked", "deprecation"})
public class KmsHierarchyWrapKeyMaterial implements MaterialWrapping_Compile.WrapMaterial, Actions_Compile.ActionWithResult, software.amazon.cryptography.materialproviders.internaldafny.types.Error>, Actions_Compile.Action, software.amazon.cryptography.materialproviders.internaldafny.types.Error>> {
  public KmsHierarchyWrapKeyMaterial() {
    this._branchKey = dafny.DafnySequence. empty(BoundedInts_Compile.uint8._typeDescriptor());
    this._branchKeyIdUtf8 = UTF8.ValidUTF8Bytes.defaultValue();
    this._branchKeyVersionAsBytes = dafny.DafnySequence. empty(BoundedInts_Compile.uint8._typeDescriptor());
    this._crypto = null;
  }
  public void __ctor(dafny.DafnySequence branchKey, dafny.DafnySequence branchKeyIdUtf8, dafny.DafnySequence branchKeyVersionAsBytes, software.amazon.cryptography.primitives.internaldafny.AtomicPrimitivesClient crypto)
  {
    (this)._branchKey = branchKey;
    (this)._branchKeyIdUtf8 = branchKeyIdUtf8;
    (this)._branchKeyVersionAsBytes = branchKeyVersionAsBytes;
    (this)._crypto = crypto;
  }
  public Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> Invoke(MaterialWrapping_Compile.WrapInput input)
  {
    Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> res = Wrappers_Compile.Result., software.amazon.cryptography.materialproviders.internaldafny.types.Error>Default(MaterialWrapping_Compile.WrapOutput._typeDescriptor(HierarchyWrapInfo._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), MaterialWrapping_Compile.WrapOutput.Default(HierarchyWrapInfo._typeDescriptor(), HierarchyWrapInfo.Default()));
    software.amazon.cryptography.materialproviders.internaldafny.types.AlgorithmSuiteInfo _0_suite;
    _0_suite = (input).dtor_algorithmSuite();
    Wrappers_Compile.Result, software.amazon.cryptography.primitives.internaldafny.types.Error> _1_maybeNonceSalt;
    Wrappers_Compile.Result, software.amazon.cryptography.primitives.internaldafny.types.Error> _out0;
    _out0 = ((this).crypto()).GenerateRandomBytes(software.amazon.cryptography.primitives.internaldafny.types.GenerateRandomBytesInput.create((int) ((__default.H__WRAP__SALT__LEN()) + (__default.H__WRAP__NONCE__LEN()))));
    _1_maybeNonceSalt = _out0;
    Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> _2_valueOrError0 = Wrappers_Compile.Result., software.amazon.cryptography.materialproviders.internaldafny.types.Error>Default(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), dafny.DafnySequence. empty(BoundedInts_Compile.uint8._typeDescriptor()));
    _2_valueOrError0 = (_1_maybeNonceSalt).MapFailure(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.primitives.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), ((java.util.function.Function)(_3_e_boxed0) -> {
      software.amazon.cryptography.primitives.internaldafny.types.Error _3_e = ((software.amazon.cryptography.primitives.internaldafny.types.Error)(java.lang.Object)(_3_e_boxed0));
      return software.amazon.cryptography.materialproviders.internaldafny.types.Error.create_AwsCryptographyPrimitives(_3_e);
    }));
    if ((_2_valueOrError0).IsFailure(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
      res = (_2_valueOrError0).>PropagateFailure(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), MaterialWrapping_Compile.WrapOutput._typeDescriptor(HierarchyWrapInfo._typeDescriptor()));
      return res;
    }
    dafny.DafnySequence _4_saltAndNonce;
    _4_saltAndNonce = (_2_valueOrError0).Extract(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
    dafny.DafnySequence _5_salt;
    _5_salt = (_4_saltAndNonce).subsequence(dafny.Helpers.toInt((java.math.BigInteger.ZERO)), __default.H__WRAP__SALT__LEN());
    dafny.DafnySequence _6_nonce;
    _6_nonce = (_4_saltAndNonce).drop(__default.H__WRAP__SALT__LEN());
    Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> _7_valueOrError1 = Wrappers_Compile.Result., software.amazon.cryptography.materialproviders.internaldafny.types.Error>Default(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), dafny.DafnySequence. empty(BoundedInts_Compile.uint8._typeDescriptor()));
    _7_valueOrError1 = CanonicalEncryptionContext_Compile.__default.EncryptionContextToAAD((input).dtor_encryptionContext());
    if ((_7_valueOrError1).IsFailure(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
      res = (_7_valueOrError1).>PropagateFailure(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), MaterialWrapping_Compile.WrapOutput._typeDescriptor(HierarchyWrapInfo._typeDescriptor()));
      return res;
    }
    dafny.DafnySequence _8_serializedEC;
    _8_serializedEC = (_7_valueOrError1).Extract(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
    dafny.DafnySequence _9_wrappingAad;
    _9_wrappingAad = __default.WrappingAad((this).branchKeyIdUtf8(), (this).branchKeyVersionAsBytes(), _8_serializedEC);
    Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> _10_valueOrError2 = Wrappers_Compile.Result., software.amazon.cryptography.materialproviders.internaldafny.types.Error>Default(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), dafny.DafnySequence. empty(BoundedInts_Compile.uint8._typeDescriptor()));
    Wrappers_Compile.Result, software.amazon.cryptography.materialproviders.internaldafny.types.Error> _out1;
    _out1 = __default.DeriveEncryptionKeyFromBranchKey((this).branchKey(), _5_salt, Wrappers_Compile.Option.>create_Some(UTF8.ValidUTF8Bytes._typeDescriptor(), Constants_Compile.__default.PROVIDER__ID__HIERARCHY()), (this).crypto());
    _10_valueOrError2 = _out1;
    if ((_10_valueOrError2).IsFailure(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
      res = (_10_valueOrError2).>PropagateFailure(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), MaterialWrapping_Compile.WrapOutput._typeDescriptor(HierarchyWrapInfo._typeDescriptor()));
      return res;
    }
    dafny.DafnySequence _11_derivedBranchKey;
    _11_derivedBranchKey = (_10_valueOrError2).Extract(dafny.DafnySequence._typeDescriptor(BoundedInts_Compile.uint8._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
    Wrappers_Compile.Result _12_maybeWrappedPdk;
    Wrappers_Compile.Result _out2;
    _out2 = ((this).crypto()).AESEncrypt(software.amazon.cryptography.primitives.internaldafny.types.AESEncryptInput.create(__default.AES__256__ENC__ALG(), _6_nonce, _11_derivedBranchKey, (input).dtor_plaintextMaterial(), _9_wrappingAad));
    _12_maybeWrappedPdk = _out2;
    Wrappers_Compile.Result _13_valueOrError3 = Wrappers_Compile.Result.Default(software.amazon.cryptography.primitives.internaldafny.types.AESEncryptOutput._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.primitives.internaldafny.types.AESEncryptOutput.Default());
    _13_valueOrError3 = (_12_maybeWrappedPdk).MapFailure(software.amazon.cryptography.primitives.internaldafny.types.AESEncryptOutput._typeDescriptor(), software.amazon.cryptography.primitives.internaldafny.types.Error._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), ((java.util.function.Function)(_14_e_boxed0) -> {
      software.amazon.cryptography.primitives.internaldafny.types.Error _14_e = ((software.amazon.cryptography.primitives.internaldafny.types.Error)(java.lang.Object)(_14_e_boxed0));
      return software.amazon.cryptography.materialproviders.internaldafny.types.Error.create_AwsCryptographyPrimitives(_14_e);
    }));
    if ((_13_valueOrError3).IsFailure(software.amazon.cryptography.primitives.internaldafny.types.AESEncryptOutput._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor())) {
      res = (_13_valueOrError3).>PropagateFailure(software.amazon.cryptography.primitives.internaldafny.types.AESEncryptOutput._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), MaterialWrapping_Compile.WrapOutput._typeDescriptor(HierarchyWrapInfo._typeDescriptor()));
      return res;
    }
    software.amazon.cryptography.primitives.internaldafny.types.AESEncryptOutput _15_wrappedPdk;
    _15_wrappedPdk = (_13_valueOrError3).Extract(software.amazon.cryptography.primitives.internaldafny.types.AESEncryptOutput._typeDescriptor(), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor());
    MaterialWrapping_Compile.WrapOutput _16_output;
    _16_output = MaterialWrapping_Compile.WrapOutput.create(HierarchyWrapInfo._typeDescriptor(), dafny.DafnySequence.concatenate(dafny.DafnySequence.concatenate(dafny.DafnySequence.concatenate(dafny.DafnySequence.concatenate(_5_salt, _6_nonce), (this).branchKeyVersionAsBytes()), (_15_wrappedPdk).dtor_cipherText()), (_15_wrappedPdk).dtor_authTag()), AwsKmsHierarchicalKeyring_Compile.HierarchyWrapInfo.create());
    res = Wrappers_Compile.Result., software.amazon.cryptography.materialproviders.internaldafny.types.Error>create_Success(MaterialWrapping_Compile.WrapOutput._typeDescriptor(HierarchyWrapInfo._typeDescriptor()), software.amazon.cryptography.materialproviders.internaldafny.types.Error._typeDescriptor(), _16_output);
    return res;
  }
  public dafny.DafnySequence _branchKey;
  public dafny.DafnySequence branchKey()
  {
    return this._branchKey;
  }
  public dafny.DafnySequence _branchKeyIdUtf8;
  public dafny.DafnySequence branchKeyIdUtf8()
  {
    return this._branchKeyIdUtf8;
  }
  public dafny.DafnySequence _branchKeyVersionAsBytes;
  public dafny.DafnySequence branchKeyVersionAsBytes()
  {
    return this._branchKeyVersionAsBytes;
  }
  public software.amazon.cryptography.primitives.internaldafny.AtomicPrimitivesClient _crypto;
  public software.amazon.cryptography.primitives.internaldafny.AtomicPrimitivesClient crypto()
  {
    return this._crypto;
  }
  private static final dafny.TypeDescriptor _TYPE = dafny.TypeDescriptor.referenceWithInitializer(KmsHierarchyWrapKeyMaterial.class, () -> (KmsHierarchyWrapKeyMaterial) null);
  public static dafny.TypeDescriptor _typeDescriptor() {
    return (dafny.TypeDescriptor) (dafny.TypeDescriptor) _TYPE;
  }
  @Override
  public java.lang.String toString() {
    return "AwsKmsHierarchicalKeyring.KmsHierarchyWrapKeyMaterial";
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy