Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
d42f1be8
Commit
d42f1be8
authored
3 years ago
by
Rubin Xu
Committed by
Gerrit Code Review
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Keystore 2.0: Add key migration API."
parents
ca57ecee
cbe7e963
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
keystore/java/android/security/AndroidKeyStoreMaintenance.java
+35
-0
35 additions, 0 deletions
...ore/java/android/security/AndroidKeyStoreMaintenance.java
with
35 additions
and
0 deletions
keystore/java/android/security/AndroidKeyStoreMaintenance.java
+
35
−
0
View file @
d42f1be8
...
...
@@ -22,6 +22,7 @@ import android.os.ServiceManager;
import
android.os.ServiceSpecificException
;
import
android.security.maintenance.IKeystoreMaintenance
;
import
android.system.keystore2.Domain
;
import
android.system.keystore2.KeyDescriptor
;
import
android.system.keystore2.ResponseCode
;
import
android.util.Log
;
...
...
@@ -33,6 +34,9 @@ public class AndroidKeyStoreMaintenance {
private
static
final
String
TAG
=
"AndroidKeyStoreMaintenance"
;
public
static
final
int
SYSTEM_ERROR
=
ResponseCode
.
SYSTEM_ERROR
;
public
static
final
int
INVALID_ARGUMENT
=
ResponseCode
.
INVALID_ARGUMENT
;
public
static
final
int
PERMISSION_DENIED
=
ResponseCode
.
PERMISSION_DENIED
;
public
static
final
int
KEY_NOT_FOUND
=
ResponseCode
.
KEY_NOT_FOUND
;
private
static
IKeystoreMaintenance
getService
()
{
return
IKeystoreMaintenance
.
Stub
.
asInterface
(
...
...
@@ -148,4 +152,35 @@ public class AndroidKeyStoreMaintenance {
Log
.
e
(
TAG
,
"Error while reporting device off body event."
,
e
);
}
}
/**
* Migrates a key given by the source descriptor to the location designated by the destination
* descriptor.
*
* @param source - The key to migrate may be specified by Domain.APP, Domain.SELINUX, or
* Domain.KEY_ID. The caller needs the permissions use, delete, and grant for the
* source namespace.
* @param destination - The new designation for the key may be specified by Domain.APP or
* Domain.SELINUX. The caller need the permission rebind for the destination
* namespace.
*
* @return * 0 on success
* * KEY_NOT_FOUND if the source did not exists.
* * PERMISSION_DENIED if any of the required permissions was missing.
* * INVALID_ARGUMENT if the destination was occupied or any domain value other than
* the allowed once were specified.
* * SYSTEM_ERROR if an unexpected error occurred.
*/
public
static
int
migrateKeyNamespace
(
KeyDescriptor
source
,
KeyDescriptor
destination
)
{
try
{
getService
().
migrateKeyNamespace
(
source
,
destination
);
return
0
;
}
catch
(
ServiceSpecificException
e
)
{
Log
.
e
(
TAG
,
"migrateKeyNamespace failed"
,
e
);
return
e
.
errorCode
;
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"Can not connect to keystore"
,
e
);
return
SYSTEM_ERROR
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment