def loads(cls, data, store_password, try_decrypt_keys=True):
        """
        See :meth:`jks.jks.KeyStore.loads`.

        :param bytes data: Byte string representation of the keystore to be loaded.
        :param str password: Keystore password string
        :param bool try_decrypt_keys: Whether to automatically try to decrypt any encountered key entries using the same password
                                      as the keystore password.

        :returns: A loaded :class:`BksKeyStore` instance, if the keystore could be successfully parsed and the supplied store password is correct.

                  If the ``try_decrypt_keys`` parameters was set to ``True``, any keys that could be successfully decrypted using the
                  store password have already been decrypted; otherwise, no atttempt to decrypt any key entries is made.

        :raises BadKeystoreFormatException: If the keystore is malformed in some way
        :raises UnsupportedKeystoreVersionException: If the keystore contains an unknown format version number
        :raises KeystoreSignatureException: If the keystore signature could not be verified using the supplied store password
        :raises DuplicateAliasException: If the keystore contains duplicate aliases
        """
        try:
            pos = 0
            version = b4.unpack_from(data, pos)[0]; pos += 4
            if version not in [1,2]:
                raise UnsupportedKeystoreVersionException("Unsupported BKS keystore version; only V1 and V2 supported, found v"+repr(version))

            salt, pos = cls._read_data(data, pos)
            iteration_count = b4.unpack_from(data, pos)[0]; pos += 4

            store_type = "bks"
            entries, size = cls._load_bks_entries(data[pos:], store_type, store_password, try_decrypt_keys=try_decrypt_keys)

            hmac_fn = hashlib.sha1
            hmac_digest_size = hmac_fn().digest_size
            hmac_key_size = hmac_digest_size*8 if version != 1 else hmac_digest_size
            hmac_key = rfc7292.derive_key(hmac_fn, rfc7292.PURPOSE_MAC_MATERIAL, store_password, salt, iteration_count, hmac_key_size//8)

            store_data = data[pos:pos+size]
            store_hmac = data[pos+size:pos+size+hmac_digest_size]
            if len(store_hmac) != hmac_digest_size:
                raise BadKeystoreFormatException("Bad HMAC size; found %d bytes, expected %d bytes" % (len(store_hmac), hmac_digest_size))

            hmac = HMAC.new(hmac_key, digestmod=SHA)
            hmac.update(store_data)

            computed_hmac = hmac.digest()
            if store_hmac != computed_hmac:
                raise KeystoreSignatureException("Hash mismatch; incorrect keystore password?")
            return cls(store_type, entries, version=version)

        except struct.error as e:
            raise BadKeystoreFormatException(e)
def loads ( cls , data , store_password , try_decrypt_keys = True ) : try : pos = 0 version = b4 . unpack_from ( data , pos ) [ 0 ] ; pos += 4 if version not in [ 1 , 2 ] : raise UnsupportedKeystoreVersionException ( "Unsupported BKS keystore version; only V1 and V2 supported, found v" + repr ( version ) ) salt , pos = cls . _read_data ( data , pos ) iteration_count = b4 . unpack_from ( data , pos ) [ 0 ] ; pos += 4 store_type = "bks" entries , size = cls . _load_bks_entries ( data [ pos : ] , store_type , store_password , try_decrypt_keys = try_decrypt_keys ) hmac_fn = hashlib . sha1 hmac_digest_size = hmac_fn ( ) . digest_size hmac_key_size = hmac_digest_size * 8 if version != 1 else hmac_digest_size hmac_key = rfc7292 . derive_key ( hmac_fn , rfc7292 . PURPOSE_MAC_MATERIAL , store_password , salt , iteration_count , hmac_key_size // 8 ) store_data = data [ pos : pos + size ] store_hmac = data [ pos + size : pos + size + hmac_digest_size ] if len ( store_hmac ) != hmac_digest_size : raise BadKeystoreFormatException ( "Bad HMAC size; found %d bytes, expected %d bytes" % ( len ( store_hmac ) , hmac_digest_size ) ) hmac = HMAC . new ( hmac_key , digestmod = SHA ) hmac . update ( store_data ) computed_hmac = hmac . digest ( ) if store_hmac != computed_hmac : raise KeystoreSignatureException ( "Hash mismatch; incorrect keystore password?" ) return cls ( store_type , entries , version = version ) except struct . error as e : raise BadKeystoreFormatException ( e )
See :meth:`jks.jks.KeyStore.loads`.

        :param bytes data: Byte string representation of the keystore to be loaded.
        :param str password: Keystore password string
        :param bool try_decrypt_keys: Whether to automatically try to decrypt any encountered key entries using the same password
                                      as the keystore password.

        :returns: A loaded :class:`BksKeyStore` instance, if the keystore could be successfully parsed and the supplied store password is correct.

                  If the ``try_decrypt_keys`` parameters was set to ``True``, any keys that could be successfully decrypted using the
                  store password have already been decrypted; otherwise, no atttempt to decrypt any key entries is made.

        :raises BadKeystoreFormatException: If the keystore is malformed in some way
        :raises UnsupportedKeystoreVersionException: If the keystore contains an unknown format version number
        :raises KeystoreSignatureException: If the keystore signature could not be verified using the supplied store password
        :raises DuplicateAliasException: If the keystore contains duplicate aliases