Source code for sdkms.v1.apis.digest_api

# coding: utf-8

"""
    Fortanix DSM REST API

    This is a set of REST APIs for accessing the Fortanix Data Security Manager. This includes APIs for managing accounts, and for performing cryptographic and key management operations. 

    OpenAPI spec version: 1.0.0-20200608
    Contact: support@fortanix.com
    Generated by: https://github.com/swagger-api/swagger-codegen.git

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    
        http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
"""


from __future__ import absolute_import

import sys
import os
import re

# python 2 and python 3 compatibility library
from six import iteritems

from ..api_client import ApiClient


# NOTE: This class is auto generated by the swagger code generator program.
# Do not edit the class manually.
# Ref: https://github.com/swagger-api/swagger-codegen
[docs]class DigestApi(object):
[docs] def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client
[docs] def batch_mac(self, body, async_call=False, **kwargs): """ Message to compute a cryptographic Message Authentication Code and the key ids to be used are provided in the request body. The MAC is returned in the response body. The ordering of the body matches the ordering of the request. An individual status code is returned for each batch item. Maximum size of the entire batch request is 512 KB. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type body: `BatchMacRequest` :param body: Batch MAC request (required) :rtype: `BatchMacResponse` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.batch_mac_with_http_info(body, async_call=async_call, **kwargs) else: (data) = self.batch_mac_with_http_info(body, async_call=async_call, **kwargs) return data
def batch_mac_with_http_info(self, body, async_call=False, **kwargs): """ Message to compute a cryptographic Message Authentication Code and the key ids to be used are provided in the request body. The MAC is returned in the response body. The ordering of the body matches the ordering of the request. An individual status code is returned for each batch item. Maximum size of the entire batch request is 512 KB. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.batch_mac_with_http_info(body, async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type body: `BatchMacRequest` :param body: Batch MAC request (required) :rtype: `BatchMacResponse` :return: If the method is called asynchronously, returns the request thread. """ all_params = ['body'] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method batch_mac" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'body' is set if ('body' not in params) or (params['body'] is None): raise ValueError("Missing the required parameter `body` when calling `batch_mac`") collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/crypto/v1/keys/batch/mac', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='BatchMacResponse', auth_settings=auth_settings, async_call=params.get('async_call'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)
[docs] def batch_mac_verify(self, body, async_call=False, **kwargs): """ The data to be MACed, the algorithm, a pre-computed MAC are provided in the request body, and the key id to be used are provided in the request body. The MAC is returned in the response body. The ordering of the body matches the ordering of the request. An individual status code is returned for each batch item. Maximum size of the entire batch request is 512 KB. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type body: `BatchMacVerifyRequest` :param body: Batch MAC verify request (required) :rtype: `BatchVerifyResponse` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.batch_mac_verify_with_http_info(body, async_call=async_call, **kwargs) else: (data) = self.batch_mac_verify_with_http_info(body, async_call=async_call, **kwargs) return data
def batch_mac_verify_with_http_info(self, body, async_call=False, **kwargs): """ The data to be MACed, the algorithm, a pre-computed MAC are provided in the request body, and the key id to be used are provided in the request body. The MAC is returned in the response body. The ordering of the body matches the ordering of the request. An individual status code is returned for each batch item. Maximum size of the entire batch request is 512 KB. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.batch_mac_verify_with_http_info(body, async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type body: `BatchMacVerifyRequest` :param body: Batch MAC verify request (required) :rtype: `BatchVerifyResponse` :return: If the method is called asynchronously, returns the request thread. """ all_params = ['body'] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method batch_mac_verify" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'body' is set if ('body' not in params) or (params['body'] is None): raise ValueError("Missing the required parameter `body` when calling `batch_mac_verify`") collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/crypto/v1/keys/batch/macverify', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='BatchVerifyResponse', auth_settings=auth_settings, async_call=params.get('async_call'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)
[docs] def compute_digest(self, body, async_call=False, **kwargs): """ This returns the digest of data provided in request body using the algorithm specified in request body. Maximum size of request body supported is 512KB. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type body: `DigestRequest` :param body: Digest request (required) :rtype: `DigestResponse` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.compute_digest_with_http_info(body, async_call=async_call, **kwargs) else: (data) = self.compute_digest_with_http_info(body, async_call=async_call, **kwargs) return data
def compute_digest_with_http_info(self, body, async_call=False, **kwargs): """ This returns the digest of data provided in request body using the algorithm specified in request body. Maximum size of request body supported is 512KB. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.compute_digest_with_http_info(body, async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type body: `DigestRequest` :param body: Digest request (required) :rtype: `DigestResponse` :return: If the method is called asynchronously, returns the request thread. """ all_params = ['body'] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method compute_digest" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'body' is set if ('body' not in params) or (params['body'] is None): raise ValueError("Missing the required parameter `body` when calling `compute_digest`") collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/crypto/v1/digest', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='DigestResponse', auth_settings=auth_settings, async_call=params.get('async_call'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)
[docs] def compute_mac(self, key_id, body, async_call=False, **kwargs): """ Compute a cryptographic Message Authentication Code on a message using a symmetric key. The key must have the MACGenerate operation enabled. Asymmetric keys may not be used to generate MACs. They can be used with the sign and verify operations. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type key_id: `str` :param key_id: kid of security object (required) :type body: `MacGenerateRequest` :param body: MAC generation request (required) :rtype: `MacGenerateResponse` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.compute_mac_with_http_info(key_id, body, async_call=async_call, **kwargs) else: (data) = self.compute_mac_with_http_info(key_id, body, async_call=async_call, **kwargs) return data
def compute_mac_with_http_info(self, key_id, body, async_call=False, **kwargs): """ Compute a cryptographic Message Authentication Code on a message using a symmetric key. The key must have the MACGenerate operation enabled. Asymmetric keys may not be used to generate MACs. They can be used with the sign and verify operations. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.compute_mac_with_http_info(key_id, body, async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type key_id: `str` :param key_id: kid of security object (required) :type body: `MacGenerateRequest` :param body: MAC generation request (required) :rtype: `MacGenerateResponse` :return: If the method is called asynchronously, returns the request thread. """ all_params = ['key_id', 'body'] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method compute_mac" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'key_id' is set if ('key_id' not in params) or (params['key_id'] is None): raise ValueError("Missing the required parameter `key_id` when calling `compute_mac`") # verify the required parameter 'body' is set if ('body' not in params) or (params['body'] is None): raise ValueError("Missing the required parameter `body` when calling `compute_mac`") collection_formats = {} path_params = {} if 'key_id' in params: path_params['key-id'] = params['key_id'] query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/crypto/v1/keys/{key-id}/mac', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='MacGenerateResponse', auth_settings=auth_settings, async_call=params.get('async_call'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)
[docs] def compute_mac_ex(self, body, async_call=False, **kwargs): """ Compute a cryptographic Message Authentication Code on a message using a symmetric key. The key must have the MACGenerate operation enabled. Asymmetric keys may not be used to generate MACs. They can be used with the sign and verify operations. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type body: `MacGenerateRequestEx` :param body: MAC generation request (required) :rtype: `MacGenerateResponse` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.compute_mac_ex_with_http_info(body, async_call=async_call, **kwargs) else: (data) = self.compute_mac_ex_with_http_info(body, async_call=async_call, **kwargs) return data
def compute_mac_ex_with_http_info(self, body, async_call=False, **kwargs): """ Compute a cryptographic Message Authentication Code on a message using a symmetric key. The key must have the MACGenerate operation enabled. Asymmetric keys may not be used to generate MACs. They can be used with the sign and verify operations. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.compute_mac_ex_with_http_info(body, async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type body: `MacGenerateRequestEx` :param body: MAC generation request (required) :rtype: `MacGenerateResponse` :return: If the method is called asynchronously, returns the request thread. """ all_params = ['body'] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method compute_mac_ex" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'body' is set if ('body' not in params) or (params['body'] is None): raise ValueError("Missing the required parameter `body` when calling `compute_mac_ex`") collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/crypto/v1/mac', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='MacGenerateResponse', auth_settings=auth_settings, async_call=params.get('async_call'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)
[docs] def verify_mac(self, key_id, body, async_call=False, **kwargs): """ The data to be MACed, the algorithm, and a pre-computed MAC are provided in the request body, and the key id is provided in the URL. SDKMS computes the MAC of the data and compares it with the specified MAC, and returns the outcome of the MAC verification in the response body. Maximum size of request body supported is 512KB. Supported digest algorithms are - SHA1, SHA256, SHA384, and SHA512. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type key_id: `str` :param key_id: kid of security object (required) :type body: `MacVerifyRequest` :param body: MAC Verify request (required) :rtype: `MacVerifyResponse` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.verify_mac_with_http_info(key_id, body, async_call=async_call, **kwargs) else: (data) = self.verify_mac_with_http_info(key_id, body, async_call=async_call, **kwargs) return data
def verify_mac_with_http_info(self, key_id, body, async_call=False, **kwargs): """ The data to be MACed, the algorithm, and a pre-computed MAC are provided in the request body, and the key id is provided in the URL. SDKMS computes the MAC of the data and compares it with the specified MAC, and returns the outcome of the MAC verification in the response body. Maximum size of request body supported is 512KB. Supported digest algorithms are - SHA1, SHA256, SHA384, and SHA512. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.verify_mac_with_http_info(key_id, body, async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type key_id: `str` :param key_id: kid of security object (required) :type body: `MacVerifyRequest` :param body: MAC Verify request (required) :rtype: `MacVerifyResponse` :return: If the method is called asynchronously, returns the request thread. """ all_params = ['key_id', 'body'] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method verify_mac" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'key_id' is set if ('key_id' not in params) or (params['key_id'] is None): raise ValueError("Missing the required parameter `key_id` when calling `verify_mac`") # verify the required parameter 'body' is set if ('body' not in params) or (params['body'] is None): raise ValueError("Missing the required parameter `body` when calling `verify_mac`") collection_formats = {} path_params = {} if 'key_id' in params: path_params['key-id'] = params['key_id'] query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/crypto/v1/keys/{key-id}/macverify', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='MacVerifyResponse', auth_settings=auth_settings, async_call=params.get('async_call'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)
[docs] def verify_mac_ex(self, body, async_call=False, **kwargs): """ The data to be MACed, the algorithm, and a pre-computed MAC are provided in the request body, and the key id is provided in the URL. SDKMS computes the MAC of the data and compares it with the specified MAC, and returns the outcome of the MAC verification in the response body. Maximum size of request body supported is 512KB. Supported digest algorithms are - SHA1, SHA256, SHA384, and SHA512. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type body: `MacVerifyRequestEx` :param body: MAC Verify request (required) :rtype: `MacVerifyResponse` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.verify_mac_ex_with_http_info(body, async_call=async_call, **kwargs) else: (data) = self.verify_mac_ex_with_http_info(body, async_call=async_call, **kwargs) return data
def verify_mac_ex_with_http_info(self, body, async_call=False, **kwargs): """ The data to be MACed, the algorithm, and a pre-computed MAC are provided in the request body, and the key id is provided in the URL. SDKMS computes the MAC of the data and compares it with the specified MAC, and returns the outcome of the MAC verification in the response body. Maximum size of request body supported is 512KB. Supported digest algorithms are - SHA1, SHA256, SHA384, and SHA512. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.verify_mac_ex_with_http_info(body, async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type body: `MacVerifyRequestEx` :param body: MAC Verify request (required) :rtype: `MacVerifyResponse` :return: If the method is called asynchronously, returns the request thread. """ all_params = ['body'] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method verify_mac_ex" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'body' is set if ('body' not in params) or (params['body'] is None): raise ValueError("Missing the required parameter `body` when calling `verify_mac_ex`") collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.\ select_header_accept(['application/json']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/crypto/v1/macverify', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='MacVerifyResponse', auth_settings=auth_settings, async_call=params.get('async_call'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)