

.. _Grant Tokens: http://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token
.. _Grants: http://docs.aws.amazon.com/kms/latest/developerguide/grants.html
.. _Encryption Context: http://docs.aws.amazon.com/kms/latest/developerguide/encrypt-context.html


***
KMS
***

.. contents:: Table of Contents
   :depth: 2


======
Client
======



.. py:class:: KMS.Client

  A low-level client representing AWS Key Management Service (KMS)::

    
    import boto3
    
    client = boto3.client('kms')

  
  These are the available methods:
  
  *   :py:meth:`can_paginate`

  
  *   :py:meth:`create_alias`

  
  *   :py:meth:`create_grant`

  
  *   :py:meth:`create_key`

  
  *   :py:meth:`decrypt`

  
  *   :py:meth:`delete_alias`

  
  *   :py:meth:`describe_key`

  
  *   :py:meth:`disable_key`

  
  *   :py:meth:`disable_key_rotation`

  
  *   :py:meth:`enable_key`

  
  *   :py:meth:`enable_key_rotation`

  
  *   :py:meth:`encrypt`

  
  *   :py:meth:`generate_data_key`

  
  *   :py:meth:`generate_data_key_without_plaintext`

  
  *   :py:meth:`generate_presigned_url`

  
  *   :py:meth:`generate_random`

  
  *   :py:meth:`get_key_policy`

  
  *   :py:meth:`get_key_rotation_status`

  
  *   :py:meth:`get_paginator`

  
  *   :py:meth:`get_waiter`

  
  *   :py:meth:`list_aliases`

  
  *   :py:meth:`list_grants`

  
  *   :py:meth:`list_key_policies`

  
  *   :py:meth:`list_keys`

  
  *   :py:meth:`put_key_policy`

  
  *   :py:meth:`re_encrypt`

  
  *   :py:meth:`retire_grant`

  
  *   :py:meth:`revoke_grant`

  
  *   :py:meth:`update_alias`

  
  *   :py:meth:`update_key_description`

  

  .. py:method:: can_paginate(operation_name)

        
    Check if an operation can be paginated.
    
    :type operation_name: string
    :param operation_name: The operation name.  This is the same name
        as the method name on the client.  For example, if the
        method name is ``create_foo``, and you'd normally invoke the
        operation as ``client.create_foo(**kwargs)``, if the
        ``create_foo`` operation can be paginated, you can use the
        call ``client.get_paginator("create_foo")``.
    
    :return: ``True`` if the operation can be paginated,
        ``False`` otherwise.


  .. py:method:: create_alias(**kwargs)

    

    Creates a display name for a customer master key. An alias can be used to identify a key and should be unique. The console enforces a one-to-one mapping between the alias and a key. An alias name can contain only alphanumeric characters, forward slashes (/), underscores (_), and dashes (-). An alias must start with the word "alias" followed by a forward slash (alias/). An alias that begins with "aws" after the forward slash (alias/aws...) is reserved by Amazon Web Services (AWS). 

     

    To associate an alias with a different key, call  UpdateAlias .

     

    Note that you cannot create or update an alias that represents a key in another account.

    

    **Request Syntax** 
    ::

      response = client.create_alias(
          AliasName='string',
          TargetKeyId='string'
      )
    :type AliasName: string
    :param AliasName: **[REQUIRED]** 

      String that contains the display name. The name must start with the word "alias" followed by a forward slash (alias/). Aliases that begin with "alias/AWS" are reserved. 

      

    
    :type TargetKeyId: string
    :param TargetKeyId: **[REQUIRED]** 

      An identifier of the key for which you are creating the alias. This value cannot be another alias but can be a globally unique identifier or a fully specified ARN to a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    
    :returns: None

  .. py:method:: create_grant(**kwargs)

    

    Adds a grant to a key to specify who can access the key and under what conditions. Grants are alternate permission mechanisms to key policies. For more information about grants, see `Grants`_ in the developer guide. If a grant is absent, access to the key is evaluated based on IAM policies attached to the user. 

     
    *  ListGrants 
     
    *  RetireGrant 
     
    *  RevokeGrant 
     

     

    

    **Request Syntax** 
    ::

      response = client.create_grant(
          KeyId='string',
          GranteePrincipal='string',
          RetiringPrincipal='string',
          Operations=[
              'Decrypt'|'Encrypt'|'GenerateDataKey'|'GenerateDataKeyWithoutPlaintext'|'ReEncryptFrom'|'ReEncryptTo'|'CreateGrant'|'RetireGrant',
          ],
          Constraints={
              'EncryptionContextSubset': {
                  'string': 'string'
              },
              'EncryptionContextEquals': {
                  'string': 'string'
              }
          },
          GrantTokens=[
              'string',
          ]
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    :type GranteePrincipal: string
    :param GranteePrincipal: **[REQUIRED]** 

      Principal given permission by the grant to use the key identified by the ``keyId`` parameter.

      

    
    :type RetiringPrincipal: string
    :param RetiringPrincipal: 

      Principal given permission to retire the grant. For more information, see  RetireGrant .

      

    
    :type Operations: list
    :param Operations: 

      List of operations permitted by the grant. This can be any combination of one or more of the following values: 

       
      * Decrypt
       
      * Encrypt
       
      * GenerateDataKey
       
      * GenerateDataKeyWithoutPlaintext
       
      * ReEncryptFrom
       
      * ReEncryptTo
       
      * CreateGrant
       
      * RetireGrant
       

       

      

    
      - *(string) --* 

      
  
    :type Constraints: dict
    :param Constraints: 

      Specifies the conditions under which the actions specified by the ``Operations`` parameter are allowed. 

      

    
      - **EncryptionContextSubset** *(dict) --* The constraint equals the full encryption context.

      
        - *(string) --* 

        
          - *(string) --* 

          
    
  
      - **EncryptionContextEquals** *(dict) --* The constraint contains additional key/value pairs that serve to further limit the grant.

      
        - *(string) --* 

        
          - *(string) --* 

          
    
  
    
    :type GrantTokens: list
    :param GrantTokens: 

      For more information, see `Grant Tokens`_ . 

      

    
      - *(string) --* 

      
  
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'GrantToken': 'string',
            'GrantId': 'string'
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **GrantToken** *(string) --* 

          For more information, see `Grant Tokens`_ . 

          
        

        - **GrantId** *(string) --* 

          Unique grant identifier. You can use the *GrantId* value to revoke a grant.

          
    

  .. py:method:: create_key(**kwargs)

    

    Creates a customer master key. Customer master keys can be used to encrypt small amounts of data (less than 4K) directly, but they are most commonly used to encrypt or envelope data keys that are then used to encrypt customer data. For more information about data keys, see  GenerateDataKey and  GenerateDataKeyWithoutPlaintext .

    

    **Request Syntax** 
    ::

      response = client.create_key(
          Policy='string',
          Description='string',
          KeyUsage='ENCRYPT_DECRYPT'
      )
    :type Policy: string
    :param Policy: 

      Policy to be attached to the key. This is required and delegates back to the account. The key is the root of trust. 

      

    
    :type Description: string
    :param Description: 

      Description of the key. We recommend that you choose a description that helps your customer decide whether the key is appropriate for a task. 

      

    
    :type KeyUsage: string
    :param KeyUsage: 

      Specifies the intended use of the key. Currently this defaults to ENCRYPT/DECRYPT, and only symmetric encryption and decryption are supported. 

      

    
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'KeyMetadata': {
                'AWSAccountId': 'string',
                'KeyId': 'string',
                'Arn': 'string',
                'CreationDate': datetime(2015, 1, 1),
                'Enabled': True|False,
                'Description': 'string',
                'KeyUsage': 'ENCRYPT_DECRYPT'
            }
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **KeyMetadata** *(dict) --* 

          Metadata associated with the key.

          
          

          - **AWSAccountId** *(string) --* 

            Account ID number.

            
          

          - **KeyId** *(string) --* 

            Unique identifier for the key.

            
          

          - **Arn** *(string) --* 

            Key ARN (Amazon Resource Name).

            
          

          - **CreationDate** *(datetime) --* 

            Date the key was created.

            
          

          - **Enabled** *(boolean) --* 

            Value that specifies whether the key is enabled.

            
          

          - **Description** *(string) --* 

            The description of the key.

            
          

          - **KeyUsage** *(string) --* 

            A value that specifies what operation(s) the key can perform.

            
      
    

  .. py:method:: decrypt(**kwargs)

    

    Decrypts ciphertext. Ciphertext is plaintext that has been previously encrypted by using any of the following functions: 

     
    *  GenerateDataKey 
     
    *  GenerateDataKeyWithoutPlaintext 
     
    *  Encrypt 
     

     

     

    Note that if a caller has been granted access permissions to all keys (through, for example, IAM user policies that grant ``Decrypt`` permission on all resources), then ciphertext encrypted by using keys in other accounts where the key grants access to the caller can be decrypted. To remedy this, we recommend that you do not grant ``Decrypt`` access in an IAM user policy. Instead grant ``Decrypt`` access only in key policies. If you must grant ``Decrypt`` access in an IAM user policy, you should scope the resource to specific keys or to specific trusted accounts. 

    

    **Request Syntax** 
    ::

      response = client.decrypt(
          CiphertextBlob=b'bytes',
          EncryptionContext={
              'string': 'string'
          },
          GrantTokens=[
              'string',
          ]
      )
    :type CiphertextBlob: bytes
    :param CiphertextBlob: **[REQUIRED]** 

      Ciphertext to be decrypted. The blob includes metadata.

      

    
    :type EncryptionContext: dict
    :param EncryptionContext: 

      The encryption context. If this was specified in the  Encrypt function, it must be specified here or the decryption operation will fail. For more information, see `Encryption Context`_ . 

      

    
      - *(string) --* 

      
        - *(string) --* 

        
  

    :type GrantTokens: list
    :param GrantTokens: 

      For more information, see `Grant Tokens`_ . 

      

    
      - *(string) --* 

      
  
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'KeyId': 'string',
            'Plaintext': b'bytes'
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **KeyId** *(string) --* 

          ARN of the key used to perform the decryption. This value is returned if no errors are encountered during the operation. 

          
        

        - **Plaintext** *(bytes) --* 

          Decrypted plaintext data. This value may not be returned if the customer master key is not available or if you didn't have permission to use it.

          
    

  .. py:method:: delete_alias(**kwargs)

    

    Deletes the specified alias. To associate an alias with a different key, call  UpdateAlias .

    

    **Request Syntax** 
    ::

      response = client.delete_alias(
          AliasName='string'
      )
    :type AliasName: string
    :param AliasName: **[REQUIRED]** 

      The alias to be deleted. The name must start with the word "alias" followed by a forward slash (alias/). Aliases that begin with "alias/AWS" are reserved.

      

    
    
    :returns: None

  .. py:method:: describe_key(**kwargs)

    

    Provides detailed information about the specified customer master key.

    

    **Request Syntax** 
    ::

      response = client.describe_key(
          KeyId='string'
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier, a fully specified ARN to either an alias or a key, or an alias name prefixed by "alias/". 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Alias ARN Example - arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       
      * Alias Name Example - alias/MyAliasName
       

       

      

    
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'KeyMetadata': {
                'AWSAccountId': 'string',
                'KeyId': 'string',
                'Arn': 'string',
                'CreationDate': datetime(2015, 1, 1),
                'Enabled': True|False,
                'Description': 'string',
                'KeyUsage': 'ENCRYPT_DECRYPT'
            }
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **KeyMetadata** *(dict) --* 

          Metadata associated with the key.

          
          

          - **AWSAccountId** *(string) --* 

            Account ID number.

            
          

          - **KeyId** *(string) --* 

            Unique identifier for the key.

            
          

          - **Arn** *(string) --* 

            Key ARN (Amazon Resource Name).

            
          

          - **CreationDate** *(datetime) --* 

            Date the key was created.

            
          

          - **Enabled** *(boolean) --* 

            Value that specifies whether the key is enabled.

            
          

          - **Description** *(string) --* 

            The description of the key.

            
          

          - **KeyUsage** *(string) --* 

            A value that specifies what operation(s) the key can perform.

            
      
    

  .. py:method:: disable_key(**kwargs)

    

    Marks a key as disabled, thereby preventing its use.

    

    **Request Syntax** 
    ::

      response = client.disable_key(
          KeyId='string'
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    
    :returns: None

  .. py:method:: disable_key_rotation(**kwargs)

    Disables rotation of the specified key.

    **Request Syntax** 
    ::

      response = client.disable_key_rotation(
          KeyId='string'
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    
    :returns: None

  .. py:method:: enable_key(**kwargs)

    Marks a key as enabled, thereby permitting its use. You can have up to 25 enabled keys at one time.

    **Request Syntax** 
    ::

      response = client.enable_key(
          KeyId='string'
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    
    :returns: None

  .. py:method:: enable_key_rotation(**kwargs)

    Enables rotation of the specified customer master key.

    **Request Syntax** 
    ::

      response = client.enable_key_rotation(
          KeyId='string'
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    
    :returns: None

  .. py:method:: encrypt(**kwargs)

    

    Encrypts plaintext into ciphertext by using a customer master key. The ``Encrypt`` function has two primary use cases: 

     
    * You can encrypt up to 4 KB of arbitrary data such as an RSA key, a database password, or other sensitive customer information.
     
    * If you are moving encrypted data from one region to another, you can use this API to encrypt in the new region the plaintext data key that was used to encrypt the data in the original region. This provides you with an encrypted copy of the data key that can be decrypted in the new region and used there to decrypt the encrypted data. 
     

     

     

    Unless you are moving encrypted data from one region to another, you don't use this function to encrypt a generated data key within a region. You retrieve data keys already encrypted by calling the  GenerateDataKey or  GenerateDataKeyWithoutPlaintext function. Data keys don't need to be encrypted again by calling ``Encrypt`` . 

     

    If you want to encrypt data locally in your application, you can use the ``GenerateDataKey`` function to return a plaintext data encryption key and a copy of the key encrypted under the customer master key (CMK) of your choosing. 

    

    **Request Syntax** 
    ::

      response = client.encrypt(
          KeyId='string',
          Plaintext=b'bytes',
          EncryptionContext={
              'string': 'string'
          },
          GrantTokens=[
              'string',
          ]
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier, a fully specified ARN to either an alias or a key, or an alias name prefixed by "alias/". 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Alias ARN Example - arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       
      * Alias Name Example - alias/MyAliasName
       

       

      

    
    :type Plaintext: bytes
    :param Plaintext: **[REQUIRED]** 

      Data to be encrypted.

      

    
    :type EncryptionContext: dict
    :param EncryptionContext: 

      Name/value pair that specifies the encryption context to be used for authenticated encryption. If used here, the same value must be supplied to the ``Decrypt`` API or decryption will fail. For more information, see `Encryption Context`_ . 

      

    
      - *(string) --* 

      
        - *(string) --* 

        
  

    :type GrantTokens: list
    :param GrantTokens: 

      For more information, see `Grant Tokens`_ . 

      

    
      - *(string) --* 

      
  
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'CiphertextBlob': b'bytes',
            'KeyId': 'string'
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **CiphertextBlob** *(bytes) --* 

          The encrypted plaintext. If you are using the CLI, the value is Base64 encoded. Otherwise, it is not encoded.

          
        

        - **KeyId** *(string) --* 

          The ID of the key used during encryption.

          
    

  .. py:method:: generate_data_key(**kwargs)

    

    Generates a data key that you can use in your application to locally encrypt data. This call returns a plaintext version of the key in the ``Plaintext`` field of the response object and an encrypted copy of the key in the ``CiphertextBlob`` field. The key is encrypted by using the master key specified by the ``KeyId`` field. To decrypt the encrypted key, pass it to the ``Decrypt`` API. 

     

    We recommend that you use the following pattern to locally encrypt data: call the ``GenerateDataKey`` API, use the key returned in the ``Plaintext`` response field to locally encrypt data, and then erase the plaintext data key from memory. Store the encrypted data key (contained in the ``CiphertextBlob`` field) alongside of the locally encrypted data. 

     

    .. note::

      You should not call the ``Encrypt`` function to re-encrypt your data keys within a region. ``GenerateDataKey`` always returns the data key encrypted and tied to the customer master key that will be used to decrypt it. There is no need to decrypt it twice. 

     

    If you decide to use the optional ``EncryptionContext`` parameter, you must also store the context in full or at least store enough information along with the encrypted data to be able to reconstruct the context when submitting the ciphertext to the ``Decrypt`` API. It is a good practice to choose a context that you can reconstruct on the fly to better secure the ciphertext. For more information about how this parameter is used, see `Encryption Context`_ . 

     

    To decrypt data, pass the encrypted data key to the ``Decrypt`` API. ``Decrypt`` uses the associated master key to decrypt the encrypted data key and returns it as plaintext. Use the plaintext data key to locally decrypt your data and then erase the key from memory. You must specify the encryption context, if any, that you specified when you generated the key. The encryption context is logged by CloudTrail, and you can use this log to help track the use of particular data. 

    

    **Request Syntax** 
    ::

      response = client.generate_data_key(
          KeyId='string',
          EncryptionContext={
              'string': 'string'
          },
          NumberOfBytes=123,
          KeySpec='AES_256'|'AES_128',
          GrantTokens=[
              'string',
          ]
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier, a fully specified ARN to either an alias or a key, or an alias name prefixed by "alias/". 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Alias ARN Example - arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       
      * Alias Name Example - alias/MyAliasName
       

       

      

    
    :type EncryptionContext: dict
    :param EncryptionContext: 

      Name/value pair that contains additional data to be authenticated during the encryption and decryption processes that use the key. This value is logged by AWS CloudTrail to provide context around the data encrypted by the key. 

      

    
      - *(string) --* 

      
        - *(string) --* 

        
  

    :type NumberOfBytes: integer
    :param NumberOfBytes: 

      Integer that contains the number of bytes to generate. Common values are 128, 256, 512, and 1024. 1024 is the current limit. We recommend that you use the ``KeySpec`` parameter instead. 

      

    
    :type KeySpec: string
    :param KeySpec: 

      Value that identifies the encryption algorithm and key size to generate a data key for. Currently this can be AES_128 or AES_256. 

      

    
    :type GrantTokens: list
    :param GrantTokens: 

      For more information, see `Grant Tokens`_ . 

      

    
      - *(string) --* 

      
  
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'CiphertextBlob': b'bytes',
            'Plaintext': b'bytes',
            'KeyId': 'string'
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **CiphertextBlob** *(bytes) --* 

          Ciphertext that contains the encrypted data key. You must store the blob and enough information to reconstruct the encryption context so that the data encrypted by using the key can later be decrypted. You must provide both the ciphertext blob and the encryption context to the  Decrypt API to recover the plaintext data key and decrypt the object. 

           

          If you are using the CLI, the value is Base64 encoded. Otherwise, it is not encoded.

          
        

        - **Plaintext** *(bytes) --* 

          Plaintext that contains the data key. Use this for encryption and decryption and then remove it from memory as soon as possible. 

          
        

        - **KeyId** *(string) --* 

          System generated unique identifier of the key to be used to decrypt the encrypted copy of the data key.

          
    

  .. py:method:: generate_data_key_without_plaintext(**kwargs)

    

    Returns a data key encrypted by a customer master key without the plaintext copy of that key. Otherwise, this API functions exactly like  GenerateDataKey . You can use this API to, for example, satisfy an audit requirement that an encrypted key be made available without exposing the plaintext copy of that key. 

    

    **Request Syntax** 
    ::

      response = client.generate_data_key_without_plaintext(
          KeyId='string',
          EncryptionContext={
              'string': 'string'
          },
          KeySpec='AES_256'|'AES_128',
          NumberOfBytes=123,
          GrantTokens=[
              'string',
          ]
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier, a fully specified ARN to either an alias or a key, or an alias name prefixed by "alias/". 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Alias ARN Example - arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       
      * Alias Name Example - alias/MyAliasName
       

       

      

    
    :type EncryptionContext: dict
    :param EncryptionContext: 

      Name:value pair that contains additional data to be authenticated during the encryption and decryption processes. 

      

    
      - *(string) --* 

      
        - *(string) --* 

        
  

    :type KeySpec: string
    :param KeySpec: 

      Value that identifies the encryption algorithm and key size. Currently this can be AES_128 or AES_256. 

      

    
    :type NumberOfBytes: integer
    :param NumberOfBytes: 

      Integer that contains the number of bytes to generate. Common values are 128, 256, 512, 1024 and so on. We recommend that you use the ``KeySpec`` parameter instead. 

      

    
    :type GrantTokens: list
    :param GrantTokens: 

      For more information, see `Grant Tokens`_ . 

      

    
      - *(string) --* 

      
  
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'CiphertextBlob': b'bytes',
            'KeyId': 'string'
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **CiphertextBlob** *(bytes) --* 

          Ciphertext that contains the wrapped data key. You must store the blob and encryption context so that the key can be used in a future decrypt operation. 

           

          If you are using the CLI, the value is Base64 encoded. Otherwise, it is not encoded. 

          
        

        - **KeyId** *(string) --* 

          System generated unique identifier of the key to be used to decrypt the encrypted copy of the data key.

          
    

  .. py:method:: generate_presigned_url(ClientMethod, Params=None, ExpiresIn=3600, HttpMethod=None)

        
    Generate a presigned url given a client, its method, and arguments
    
    :type ClientMethod: string
    :param ClientMethod: The client method to presign for
    
    :type Params: dict
    :param Params: The parameters normally passed to
        ``ClientMethod``.
    
    :type ExpiresIn: int
    :param ExpiresIn: The number of seconds the presigned url is valid
        for. By default it expires in an hour (3600 seconds)
    
    :type HttpMethod: string
    :param HttpMethod: The http method to use on the generated url. By
        default, the http method is whatever is used in the method's model.
    
    :returns: The presigned url


  .. py:method:: generate_random(**kwargs)

    

    Generates an unpredictable byte string. 

    

    **Request Syntax** 
    ::

      response = client.generate_random(
          NumberOfBytes=123
      )
    :type NumberOfBytes: integer
    :param NumberOfBytes: 

      Integer that contains the number of bytes to generate. Common values are 128, 256, 512, 1024 and so on. The current limit is 1024 bytes. 

      

    
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'Plaintext': b'bytes'
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **Plaintext** *(bytes) --* 

          Plaintext that contains the unpredictable byte string.

          
    

  .. py:method:: get_key_policy(**kwargs)

    

    Retrieves a policy attached to the specified key.

    

    **Request Syntax** 
    ::

      response = client.get_key_policy(
          KeyId='string',
          PolicyName='string'
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    :type PolicyName: string
    :param PolicyName: **[REQUIRED]** 

      String that contains the name of the policy. Currently, this must be "default". Policy names can be discovered by calling  ListKeyPolicies . 

      

    
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'Policy': 'string'
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **Policy** *(string) --* 

          A policy document in JSON format.

          
    

  .. py:method:: get_key_rotation_status(**kwargs)

    Retrieves a Boolean value that indicates whether key rotation is enabled for the specified key.

    **Request Syntax** 
    ::

      response = client.get_key_rotation_status(
          KeyId='string'
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'KeyRotationEnabled': True|False
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **KeyRotationEnabled** *(boolean) --* A Boolean value that specifies whether key rotation is enabled.
    

  .. py:method:: get_paginator(operation_name)

        
    Create a paginator for an operation.
    
    :type operation_name: string
    :param operation_name: The operation name.  This is the same name
        as the method name on the client.  For example, if the
        method name is ``create_foo``, and you'd normally invoke the
        operation as ``client.create_foo(**kwargs)``, if the
        ``create_foo`` operation can be paginated, you can use the
        call ``client.get_paginator("create_foo")``.
    
    :raise OperationNotPageableError: Raised if the operation is not
        pageable.  You can use the ``client.can_paginate`` method to
        check if an operation is pageable.
    
    :rtype: L{botocore.paginate.Paginator}
    :return: A paginator object.


  .. py:method:: get_waiter(waiter_name)

        


  .. py:method:: list_aliases(**kwargs)

    

    Lists all of the key aliases in the account.

    

    **Request Syntax** 
    ::

      response = client.list_aliases(
          Limit=123,
          Marker='string'
      )
    :type Limit: integer
    :param Limit: 

      Specify this parameter when paginating results to indicate the maximum number of aliases you want in each response. If there are additional aliases beyond the maximum you specify, the ``Truncated`` response element will be set to ``true.``  

      

    
    :type Marker: string
    :param Marker: 

      Use this parameter when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the ``NextMarker`` element in the response you just received. 

      

    
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'Aliases': [
                {
                    'AliasName': 'string',
                    'AliasArn': 'string',
                    'TargetKeyId': 'string'
                },
            ],
            'NextMarker': 'string',
            'Truncated': True|False
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **Aliases** *(list) --* 

          A list of key aliases in the user's account.

          
          

          - *(dict) --* Contains information about an alias.
            

            - **AliasName** *(string) --* 

              String that contains the alias.

              
            

            - **AliasArn** *(string) --* 

              String that contains the key ARN.

              
            

            - **TargetKeyId** *(string) --* 

              String that contains the key identifier pointed to by the alias.

              
        
      
        

        - **NextMarker** *(string) --* 

          If ``Truncated`` is true, this value is present and contains the value to use for the ``Marker`` request parameter in a subsequent pagination request. 

          
        

        - **Truncated** *(boolean) --* 

          A flag that indicates whether there are more items in the list. If your results were truncated, you can make a subsequent pagination request using the ``Marker`` request parameter to retrieve more aliases in the list. 

          
    

  .. py:method:: list_grants(**kwargs)

    

    List the grants for a specified key.

    

    **Request Syntax** 
    ::

      response = client.list_grants(
          KeyId='string',
          Limit=123,
          Marker='string'
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    :type Limit: integer
    :param Limit: 

      Specify this parameter only when paginating results to indicate the maximum number of grants you want listed in the response. If there are additional grants beyond the maximum you specify, the ``Truncated`` response element will be set to ``true.``  

      

    
    :type Marker: string
    :param Marker: 

      Use this parameter only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the ``NextMarker`` in the response you just received. 

      

    
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'Grants': [
                {
                    'GrantId': 'string',
                    'GranteePrincipal': 'string',
                    'RetiringPrincipal': 'string',
                    'IssuingAccount': 'string',
                    'Operations': [
                        'Decrypt'|'Encrypt'|'GenerateDataKey'|'GenerateDataKeyWithoutPlaintext'|'ReEncryptFrom'|'ReEncryptTo'|'CreateGrant'|'RetireGrant',
                    ],
                    'Constraints': {
                        'EncryptionContextSubset': {
                            'string': 'string'
                        },
                        'EncryptionContextEquals': {
                            'string': 'string'
                        }
                    }
                },
            ],
            'NextMarker': 'string',
            'Truncated': True|False
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **Grants** *(list) --* 

          A list of grants.

          
          

          - *(dict) --* 

            Contains information about each entry in the grant list.

            
            

            - **GrantId** *(string) --* 

              Unique grant identifier.

              
            

            - **GranteePrincipal** *(string) --* 

              The principal that receives the grant permission.

              
            

            - **RetiringPrincipal** *(string) --* 

              The principal that can retire the account.

              
            

            - **IssuingAccount** *(string) --* 

              The account under which the grant was issued.

              
            

            - **Operations** *(list) --* 

              List of operations permitted by the grant. This can be any combination of one or more of the following values: 

               
              * Decrypt
               
              * Encrypt
               
              * GenerateDataKey
               
              * GenerateDataKeyWithoutPlaintext
               
              * ReEncryptFrom
               
              * ReEncryptTo
               
              * CreateGrant
               

              

              
              

              - *(string) --* 
          
            

            - **Constraints** *(dict) --* 

              Specifies the conditions under which the actions specified by the ``Operations`` parameter are allowed. 

              
              

              - **EncryptionContextSubset** *(dict) --* The constraint equals the full encryption context.
                

                - *(string) --* 
                  

                  - *(string) --* 
            
          
              

              - **EncryptionContextEquals** *(dict) --* The constraint contains additional key/value pairs that serve to further limit the grant.
                

                - *(string) --* 
                  

                  - *(string) --* 
            
          
          
        
      
        

        - **NextMarker** *(string) --* 

          If ``Truncated`` is true, this value is present and contains the value to use for the ``Marker`` request parameter in a subsequent pagination request. 

          
        

        - **Truncated** *(boolean) --* 

          A flag that indicates whether there are more items in the list. If your results were truncated, you can make a subsequent pagination request using the ``Marker`` request parameter to retrieve more grants in the list. 

          
    

  .. py:method:: list_key_policies(**kwargs)

    

    Retrieves a list of policies attached to a key.

    

    **Request Syntax** 
    ::

      response = client.list_key_policies(
          KeyId='string',
          Limit=123,
          Marker='string'
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier, a fully specified ARN to either an alias or a key, or an alias name prefixed by "alias/". 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Alias ARN Example - arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       
      * Alias Name Example - alias/MyAliasName
       

       

      

    
    :type Limit: integer
    :param Limit: 

      Specify this parameter only when paginating results to indicate the maximum number of policies you want listed in the response. If there are additional policies beyond the maximum you specify, the ``Truncated`` response element will be set to ``true.``  

      

    
    :type Marker: string
    :param Marker: 

      Use this parameter only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the ``NextMarker`` in the response you just received. 

      

    
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'PolicyNames': [
                'string',
            ],
            'NextMarker': 'string',
            'Truncated': True|False
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **PolicyNames** *(list) --* 

          A list of policy names. Currently, there is only one policy and it is named "Default".

          
          

          - *(string) --* 
      
        

        - **NextMarker** *(string) --* 

          If ``Truncated`` is true, this value is present and contains the value to use for the ``Marker`` request parameter in a subsequent pagination request. 

          
        

        - **Truncated** *(boolean) --* 

          A flag that indicates whether there are more items in the list. If your results were truncated, you can make a subsequent pagination request using the ``Marker`` request parameter to retrieve more policies in the list. 

          
    

  .. py:method:: list_keys(**kwargs)

    

    Lists the customer master keys.

    

    **Request Syntax** 
    ::

      response = client.list_keys(
          Limit=123,
          Marker='string'
      )
    :type Limit: integer
    :param Limit: 

      Specify this parameter only when paginating results to indicate the maximum number of keys you want listed in the response. If there are additional keys beyond the maximum you specify, the ``Truncated`` response element will be set to ``true.``  

      

    
    :type Marker: string
    :param Marker: 

      Use this parameter only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the ``NextMarker`` in the response you just received. 

      

    
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'Keys': [
                {
                    'KeyId': 'string',
                    'KeyArn': 'string'
                },
            ],
            'NextMarker': 'string',
            'Truncated': True|False
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **Keys** *(list) --* 

          A list of keys.

          
          

          - *(dict) --* 

            Contains information about each entry in the key list.

            
            

            - **KeyId** *(string) --* 

              Unique identifier of the key.

              
            

            - **KeyArn** *(string) --* 

              ARN of the key.

              
        
      
        

        - **NextMarker** *(string) --* 

          If ``Truncated`` is true, this value is present and contains the value to use for the ``Marker`` request parameter in a subsequent pagination request. 

          
        

        - **Truncated** *(boolean) --* 

          A flag that indicates whether there are more items in the list. If your results were truncated, you can make a subsequent pagination request using the ``Marker`` request parameter to retrieve more keys in the list. 

          
    

  .. py:method:: put_key_policy(**kwargs)

    

    Attaches a policy to the specified key.

    

    **Request Syntax** 
    ::

      response = client.put_key_policy(
          KeyId='string',
          PolicyName='string',
          Policy='string'
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    :type PolicyName: string
    :param PolicyName: **[REQUIRED]** 

      Name of the policy to be attached. Currently, the only supported name is "default".

      

    
    :type Policy: string
    :param Policy: **[REQUIRED]** 

      The policy, in JSON format, to be attached to the key.

      

    
    
    :returns: None

  .. py:method:: re_encrypt(**kwargs)

    

    Encrypts data on the server side with a new customer master key without exposing the plaintext of the data on the client side. The data is first decrypted and then encrypted. This operation can also be used to change the encryption context of a ciphertext. 

     

    Unlike other actions, ``ReEncrypt`` is authorized twice - once as ``ReEncryptFrom`` on the source key and once as ``ReEncryptTo`` on the destination key. We therefore recommend that you include the ``"action":"kms:ReEncrypt*"`` statement in your key policies to permit re-encryption from or to the key. The statement is included automatically when you authorize use of the key through the console but must be included manually when you set a policy by using the  PutKeyPolicy function. 

    

    **Request Syntax** 
    ::

      response = client.re_encrypt(
          CiphertextBlob=b'bytes',
          SourceEncryptionContext={
              'string': 'string'
          },
          DestinationKeyId='string',
          DestinationEncryptionContext={
              'string': 'string'
          },
          GrantTokens=[
              'string',
          ]
      )
    :type CiphertextBlob: bytes
    :param CiphertextBlob: **[REQUIRED]** 

      Ciphertext of the data to re-encrypt.

      

    
    :type SourceEncryptionContext: dict
    :param SourceEncryptionContext: 

      Encryption context used to encrypt and decrypt the data specified in the ``CiphertextBlob`` parameter. 

      

    
      - *(string) --* 

      
        - *(string) --* 

        
  

    :type DestinationKeyId: string
    :param DestinationKeyId: **[REQUIRED]** 

      A unique identifier for the customer master key used to re-encrypt the data. This value can be a globally unique identifier, a fully specified ARN to either an alias or a key, or an alias name prefixed by "alias/". 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Alias ARN Example - arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       
      * Alias Name Example - alias/MyAliasName
       

       

      

    
    :type DestinationEncryptionContext: dict
    :param DestinationEncryptionContext: 

      Encryption context to be used when the data is re-encrypted.

      

    
      - *(string) --* 

      
        - *(string) --* 

        
  

    :type GrantTokens: list
    :param GrantTokens: 

      For more information, see `Grant Tokens`_ . 

      

    
      - *(string) --* 

      
  
    
    :rtype: dict
    :returns: 
      
      **Response Syntax** 

      
      ::

        {
            'CiphertextBlob': b'bytes',
            'SourceKeyId': 'string',
            'KeyId': 'string'
        }
      **Response Structure** 

      

      - *(dict) --* 
        

        - **CiphertextBlob** *(bytes) --* 

          The re-encrypted data. If you are using the CLI, the value is Base64 encoded. Otherwise, it is not encoded.

          
        

        - **SourceKeyId** *(string) --* 

          Unique identifier of the key used to originally encrypt the data.

          
        

        - **KeyId** *(string) --* 

          Unique identifier of the key used to re-encrypt the data.

          
    

  .. py:method:: retire_grant(**kwargs)

    

    Retires a grant. You can retire a grant when you're done using it to clean up. You should revoke a grant when you intend to actively deny operations that depend on it. The following are permitted to call this API: 

     
    * The account that created the grant
     
    * The ``RetiringPrincipal`` , if present
     
    * The ``GranteePrincipal`` , if ``RetireGrant`` is a grantee operation
     

    The grant to retire must be identified by its grant token or by a combination of the key ARN and the grant ID. A grant token is a unique variable-length base64-encoded string. A grant ID is a 64 character unique identifier of a grant. Both are returned by the ``CreateGrant`` function. 

    

    **Request Syntax** 
    ::

      response = client.retire_grant(
          GrantToken='string',
          KeyId='string',
          GrantId='string'
      )
    :type GrantToken: string
    :param GrantToken: 

      Token that identifies the grant to be retired.

      

    
    :type KeyId: string
    :param KeyId: 

      A unique identifier for the customer master key associated with the grant. This value can be a globally unique identifier or a fully specified ARN of the key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    :type GrantId: string
    :param GrantId: 

      Unique identifier of the grant to be retired. The grant ID is returned by the ``CreateGrant`` function. 

       
      * Grant ID Example - 0123456789012345678901234567890123456789012345678901234567890123
       

       

      

    
    
    :returns: None

  .. py:method:: revoke_grant(**kwargs)

    Revokes a grant. You can revoke a grant to actively deny operations that depend on it.

    **Request Syntax** 
    ::

      response = client.revoke_grant(
          KeyId='string',
          GrantId='string'
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key associated with the grant. This value can be a globally unique identifier or the fully specified ARN to a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    :type GrantId: string
    :param GrantId: **[REQUIRED]** 

      Identifier of the grant to be revoked.

      

    
    
    :returns: None

  .. py:method:: update_alias(**kwargs)

    

    Updates an alias to associate it with a different key.

     

    An alias name can contain only alphanumeric characters, forward slashes (/), underscores (_), and dashes (-). An alias must start with the word "alias" followed by a forward slash (alias/). An alias that begins with "aws" after the forward slash (alias/aws...) is reserved by Amazon Web Services (AWS). 

     

    An alias is not a property of a key. Therefore, an alias can be associated with and disassociated from an existing key without changing the properties of the key. 

     

    Note that you cannot create or update an alias that represents a key in another account.

    

    **Request Syntax** 
    ::

      response = client.update_alias(
          AliasName='string',
          TargetKeyId='string'
      )
    :type AliasName: string
    :param AliasName: **[REQUIRED]** String that contains the name of the alias to be modifed. The name must start with the word "alias" followed by a forward slash (alias/). Aliases that begin with "alias/AWS" are reserved.

    
    :type TargetKeyId: string
    :param TargetKeyId: **[REQUIRED]** 

      Unique identifier of the customer master key to be associated with the alias. This value can be a globally unique identifier or the fully specified ARN of a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    
    :returns: None

  .. py:method:: update_key_description(**kwargs)

    

    Updates the description of a key.

    

    **Request Syntax** 
    ::

      response = client.update_key_description(
          KeyId='string',
          Description='string'
      )
    :type KeyId: string
    :param KeyId: **[REQUIRED]** 

      A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key. 

       
      * Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
       
      * Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
       

       

      

    
    :type Description: string
    :param Description: **[REQUIRED]** 

      New description for the key.

      

    
    
    :returns: None