Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DPAPI: Using CryptUnprotect before user logs in

I am using DPAPI to store an XML data. The data after CryptProtectData is stored in a file. In one of my use cases, this data needs to be decrypted before any user logs in to the workstation. Since, I cannot use user specific key in this, I am setting the flag "CRYPTPROTECT_LOCAL_MACHINE" while encrypting. Entropy key is a static text.

Unprotect is working in all the scenarios except when I am calling it before logon ( no user is logged in). Its returning error 87 (the paramter is incorrect).

I re-read the entire DPAPI documentation to see how the keys are being generated. But, unfortunately, there is not enough information for this specific flag.

Will CryptUnprotectData work in this scenario at all? Can it be called by the applications that are running under some user session? Any help is appreciated.

Thanks, D

like image 210
Wander3r Avatar asked May 14 '13 09:05

Wander3r


1 Answers

We use DPAPI to store a password required by a service:

  • Encrypt with CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN.

  • Decrypt with CRYPTPROTECT_UI_FORBIDDEN

The service runs when the machine boots (i.e. before logon); all works fine.

like image 86
user3392484 Avatar answered Sep 19 '22 10:09

user3392484