Lines Matching refs:keymaster
99 static bool generateKeymasterKey(Keymaster& keymaster, const KeyAuthentication& auth, in generateKeymasterKey() argument
101 auto paramBuilder = keymaster::AuthorizationSetBuilder() in generateKeymasterKey()
103 .Authorization(keymaster::TAG_BLOCK_MODE, KM_MODE_GCM) in generateKeymasterKey()
104 .Authorization(keymaster::TAG_MIN_MAC_LENGTH, GCM_MAC_BYTES * 8) in generateKeymasterKey()
105 .Authorization(keymaster::TAG_PADDING, KM_PAD_NONE); in generateKeymasterKey()
106 addStringParam(¶mBuilder, keymaster::TAG_APPLICATION_ID, appId); in generateKeymasterKey()
109 paramBuilder.Authorization(keymaster::TAG_NO_AUTH_REQUIRED); in generateKeymasterKey()
118 paramBuilder.Authorization(keymaster::TAG_USER_SECURE_ID, at->user_id); in generateKeymasterKey()
119 paramBuilder.Authorization(keymaster::TAG_USER_AUTH_TYPE, HW_AUTH_PASSWORD); in generateKeymasterKey()
120 paramBuilder.Authorization(keymaster::TAG_AUTH_TIMEOUT, AUTH_TIMEOUT); in generateKeymasterKey()
122 return keymaster.generateKey(paramBuilder.build(), key); in generateKeymasterKey()
125 static keymaster::AuthorizationSetBuilder beginParams(const KeyAuthentication& auth, in beginParams()
127 auto paramBuilder = keymaster::AuthorizationSetBuilder() in beginParams()
128 .Authorization(keymaster::TAG_BLOCK_MODE, KM_MODE_GCM) in beginParams()
129 .Authorization(keymaster::TAG_MAC_LENGTH, GCM_MAC_BYTES * 8) in beginParams()
130 .Authorization(keymaster::TAG_PADDING, KM_PAD_NONE); in beginParams()
131 addStringParam(¶mBuilder, keymaster::TAG_APPLICATION_ID, appId); in beginParams()
134 addStringParam(¶mBuilder, keymaster::TAG_AUTH_TOKEN, auth.token); in beginParams()
139 static bool encryptWithKeymasterKey(Keymaster& keymaster, const std::string& key, in encryptWithKeymasterKey() argument
143 keymaster::AuthorizationSet outParams; in encryptWithKeymasterKey()
144 auto opHandle = keymaster.begin(KM_PURPOSE_ENCRYPT, key, params, &outParams); in encryptWithKeymasterKey()
147 if (!outParams.GetTagValue(keymaster::TAG_NONCE, &nonceBlob)) { in encryptWithKeymasterKey()
164 static bool decryptWithKeymasterKey(Keymaster& keymaster, const std::string& key, in decryptWithKeymasterKey() argument
169 auto params = addStringParam(beginParams(auth, appId), keymaster::TAG_NONCE, nonce).build(); in decryptWithKeymasterKey()
170 auto opHandle = keymaster.begin(KM_PURPOSE_DECRYPT, key, params); in decryptWithKeymasterKey()
271 Keymaster keymaster; in storeKey() local
272 if (!keymaster) return false; in storeKey()
274 if (!generateKeymasterKey(keymaster, auth, appId, &kmKey)) return false; in storeKey()
277 if (!encryptWithKeymasterKey(keymaster, kmKey, auth, appId, key, &encryptedKey)) return false; in storeKey()
303 Keymaster keymaster; in retrieveKey() local
304 if (!keymaster) return false; in retrieveKey()
305 return decryptWithKeymasterKey(keymaster, kmKey, auth, appId, encryptedMessage, key); in retrieveKey()
311 Keymaster keymaster; in deleteKey() local
312 if (!keymaster) return false; in deleteKey()
313 if (!keymaster.deleteKey(kmKey)) return false; in deleteKey()