Skip to content

Commit 1b3b6b9

Browse files
committed
fix: access(value,policy) no longer strips tags — treats as raw untagged ciphertext
Two clean modes: access(value) → tagged: auto-detect tag, strip it, decrypt access(value, policy) → untagged: no tag stripping, decrypt raw
1 parent 78bd268 commit 1b3b6b9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

cyphera/sdk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def protect(self, value: str, policy_name: str) -> str:
148148
def access(self, protected_value: str, policy_name: str = None) -> str:
149149
if policy_name:
150150
policy = self._get_policy(policy_name)
151-
return self._access_fpe(protected_value, policy)
151+
return self._access_fpe(protected_value, policy, explicit_policy=True)
152152

153153
# Tag-based lookup — longest tags first
154154
for tag in sorted(self._tag_index.keys(), key=len, reverse=True):
@@ -185,16 +185,16 @@ def _protect_fpe(self, value: str, policy: dict, is_ff3: bool) -> str:
185185
return policy["tag"] + result
186186
return result
187187

188-
def _access_fpe(self, protected_value: str, policy: dict) -> str:
188+
def _access_fpe(self, protected_value: str, policy: dict, explicit_policy: bool = False) -> str:
189189
if policy["engine"] not in ("ff1", "ff3"):
190190
raise ValueError(f"Cannot reverse '{policy['engine']}' — not reversible")
191191

192192
key = self._resolve_key(policy["key_ref"])
193193
alphabet = policy["alphabet"]
194194

195-
# Strip tag
195+
# Strip tag (only when auto-detected, not when policy explicitly provided)
196196
without_tag = protected_value
197-
if policy["tag_enabled"] and policy["tag"]:
197+
if not explicit_policy and policy["tag_enabled"] and policy["tag"]:
198198
without_tag = protected_value[len(policy["tag"]):]
199199

200200
# Strip passthroughs

0 commit comments

Comments
 (0)