MCPcopy
hub / github.com/ddworken/hishtory / DecryptHistoryEntry

Function DecryptHistoryEntry

client/data/data.go:155–172  ·  view source on GitHub ↗
(userSecret string, entry shared.EncHistoryEntry)

Source from the content-addressed store, hash-verified

153}
154
155func DecryptHistoryEntry(userSecret string, entry shared.EncHistoryEntry) (HistoryEntry, error) {
156 if entry.UserId != UserId(userSecret) {
157 return HistoryEntry{}, fmt.Errorf("refusing to decrypt history entry with mismatching UserId")
158 }
159 plaintext, err := Decrypt(userSecret, entry.EncryptedData, []byte(UserId(userSecret)), entry.Nonce)
160 if err != nil {
161 return HistoryEntry{}, nil
162 }
163 var decryptedEntry HistoryEntry
164 err = json.Unmarshal(plaintext, &decryptedEntry)
165 if err != nil {
166 return HistoryEntry{}, nil
167 }
168 if decryptedEntry.EntryId != "" && entry.EncryptedId != "" && decryptedEntry.EntryId != entry.EncryptedId {
169 return HistoryEntry{}, fmt.Errorf("rejecting encrypted history entry that contains mismatching IDs (outer=%s inner=%s)", entry.EncryptedId, decryptedEntry.EntryId)
170 }
171 return decryptedEntry, nil
172}
173
174func ValidateHishtoryPath() error {
175 hishtoryPath := os.Getenv("HISHTORY_PATH")

Callers 5

TestESubmitThenQueryFunction · 0.92
TestDeletionRequestsFunction · 0.92

Calls 2

UserIdFunction · 0.85
DecryptFunction · 0.85

Tested by 3

TestESubmitThenQueryFunction · 0.74
TestDeletionRequestsFunction · 0.74