@@ -5,8 +5,10 @@ mod unsealed;
55use crate :: traits:: { Encryptable , ReadConversionError , Searchable , WriteConversionError } ;
66use cipherstash_client:: {
77 credentials:: { vitur_credentials:: ViturToken , Credentials } ,
8- encryption:: { Encryption , EncryptionError , Plaintext , TypeParseError } ,
9- schema:: column:: Index ,
8+ encryption:: {
9+ compound_indexer:: { CompoundIndex , ExactIndex } ,
10+ Encryption , EncryptionError , Plaintext , TypeParseError ,
11+ } ,
1012} ;
1113use thiserror:: Error ;
1214
@@ -56,15 +58,26 @@ pub(crate) fn all_index_keys<E: Searchable + Encryptable>(sort_key: &str) -> Vec
5658 . collect ( )
5759}
5860
59- pub ( crate ) fn hmac < C > ( value : & str , cipher : & Encryption < C > ) -> Result < String , EncryptionError >
61+ pub ( crate ) fn hmac < C > (
62+ field : & str ,
63+ value : & str ,
64+ salt : Option < & str > ,
65+ cipher : & Encryption < C > ,
66+ ) -> Result < String , EncryptionError >
6067where
6168 C : Credentials < Token = ViturToken > ,
6269{
6370 let plaintext = Plaintext :: Utf8Str ( Some ( value. to_string ( ) ) ) ;
64- let index_type = Index :: new_unique ( ) . index_type ;
71+ let index = CompoundIndex :: new ( ExactIndex :: new ( field , vec ! [ ] ) ) ;
6572
6673 cipher
67- . index ( & plaintext, & index_type) ?
74+ . compound_index (
75+ & index,
76+ plaintext,
77+ // passing None here results in no terms so pass an empty string
78+ Some ( salt. unwrap_or ( "" ) ) ,
79+ 16 ,
80+ ) ?
6881 . as_binary ( )
6982 . map ( hex:: encode)
7083 . ok_or ( EncryptionError :: IndexingError (
0 commit comments