summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndres Morales2015-05-18 11:26:19 -0500
committerAndres Morales2015-05-26 21:19:40 -0500
commit2aea55647d8eda7f4fc540dcfac30c753de75adb (patch)
tree700752e435fcdeb492663b28237bd98996a849bb /gatekeeperd/IGateKeeperService.cpp
parent1cf0580969a09fcbf84d5870da989287e628ce9b (diff)
downloadplatform-system-core-2aea55647d8eda7f4fc540dcfac30c753de75adb.tar.gz
platform-system-core-2aea55647d8eda7f4fc540dcfac30c753de75adb.tar.xz
platform-system-core-2aea55647d8eda7f4fc540dcfac30c753de75adb.zip
[gatekeeperd] return brute-force throttling information
Bug: 21118563 Change-Id: I13c6a44f61668be8b4c1fde8c84dcfebab84517c
Diffstat (limited to 'gatekeeperd/IGateKeeperService.cpp')
-rw-r--r--gatekeeperd/IGateKeeperService.cpp52
1 files changed, 40 insertions, 12 deletions
diff --git a/gatekeeperd/IGateKeeperService.cpp b/gatekeeperd/IGateKeeperService.cpp
index f5bbbf1f2..95fbfd10b 100644
--- a/gatekeeperd/IGateKeeperService.cpp
+++ b/gatekeeperd/IGateKeeperService.cpp
@@ -50,18 +50,25 @@ status_t BnGateKeeperService::onTransact(
50 50
51 uint8_t *out = NULL; 51 uint8_t *out = NULL;
52 uint32_t outSize = 0; 52 uint32_t outSize = 0;
53 status_t ret = enroll(uid, currentPasswordHandle, currentPasswordHandleSize, 53 int ret = enroll(uid, currentPasswordHandle, currentPasswordHandleSize,
54 currentPassword, currentPasswordSize, desiredPassword, 54 currentPassword, currentPasswordSize, desiredPassword,
55 desiredPasswordSize, &out, &outSize); 55 desiredPasswordSize, &out, &outSize);
56 56
57 reply->writeNoException(); 57 reply->writeNoException();
58 if (ret == NO_ERROR && outSize > 0 && out != NULL) { 58 reply->writeInt32(1);
59 if (ret == 0 && outSize > 0 && out != NULL) {
60 reply->writeInt32(GATEKEEPER_RESPONSE_OK);
61 reply->writeInt32(0);
62 reply->writeInt32(outSize);
59 reply->writeInt32(outSize); 63 reply->writeInt32(outSize);
60 void *buf = reply->writeInplace(outSize); 64 void *buf = reply->writeInplace(outSize);
61 memcpy(buf, out, outSize); 65 memcpy(buf, out, outSize);
62 free(out); 66 delete[] out;
67 } else if (ret > 0) {
68 reply->writeInt32(GATEKEEPER_RESPONSE_RETRY);
69 reply->writeInt32(ret);
63 } else { 70 } else {
64 reply->writeInt32(-1); 71 reply->writeInt32(GATEKEEPER_RESPONSE_ERROR);
65 } 72 }
66 return NO_ERROR; 73 return NO_ERROR;
67 } 74 }
@@ -78,10 +85,23 @@ status_t BnGateKeeperService::onTransact(
78 static_cast<const uint8_t *>(data.readInplace(currentPasswordSize)); 85 static_cast<const uint8_t *>(data.readInplace(currentPasswordSize));
79 if (!currentPassword) currentPasswordSize = 0; 86 if (!currentPassword) currentPasswordSize = 0;
80 87
81 status_t ret = verify(uid, (uint8_t *) currentPasswordHandle, 88 bool request_reenroll = false;
82 currentPasswordHandleSize, (uint8_t *) currentPassword, currentPasswordSize); 89 int ret = verify(uid, (uint8_t *) currentPasswordHandle,
90 currentPasswordHandleSize, (uint8_t *) currentPassword, currentPasswordSize,
91 &request_reenroll);
92
83 reply->writeNoException(); 93 reply->writeNoException();
84 reply->writeInt32(ret == NO_ERROR ? 1 : 0); 94 reply->writeInt32(1);
95 if (ret == 0) {
96 reply->writeInt32(GATEKEEPER_RESPONSE_OK);
97 reply->writeInt32(request_reenroll ? 1 : 0);
98 reply->writeInt32(0); // no payload returned from this call
99 } else if (ret > 0) {
100 reply->writeInt32(GATEKEEPER_RESPONSE_RETRY);
101 reply->writeInt32(ret);
102 } else {
103 reply->writeInt32(GATEKEEPER_RESPONSE_ERROR);
104 }
85 return NO_ERROR; 105 return NO_ERROR;
86 } 106 }
87 case VERIFY_CHALLENGE: { 107 case VERIFY_CHALLENGE: {
@@ -101,17 +121,25 @@ status_t BnGateKeeperService::onTransact(
101 121
102 uint8_t *out = NULL; 122 uint8_t *out = NULL;
103 uint32_t outSize = 0; 123 uint32_t outSize = 0;
104 status_t ret = verifyChallenge(uid, challenge, (uint8_t *) currentPasswordHandle, 124 bool request_reenroll = false;
125 int ret = verifyChallenge(uid, challenge, (uint8_t *) currentPasswordHandle,
105 currentPasswordHandleSize, (uint8_t *) currentPassword, currentPasswordSize, 126 currentPasswordHandleSize, (uint8_t *) currentPassword, currentPasswordSize,
106 &out, &outSize); 127 &out, &outSize, &request_reenroll);
107 reply->writeNoException(); 128 reply->writeNoException();
108 if (ret == NO_ERROR && outSize > 0 && out != NULL) { 129 reply->writeInt32(1);
130 if (ret == 0 && outSize > 0 && out != NULL) {
131 reply->writeInt32(GATEKEEPER_RESPONSE_OK);
132 reply->writeInt32(request_reenroll ? 1 : 0);
133 reply->writeInt32(outSize);
109 reply->writeInt32(outSize); 134 reply->writeInt32(outSize);
110 void *buf = reply->writeInplace(outSize); 135 void *buf = reply->writeInplace(outSize);
111 memcpy(buf, out, outSize); 136 memcpy(buf, out, outSize);
112 free(out); 137 delete[] out;
138 } else if (ret > 0) {
139 reply->writeInt32(GATEKEEPER_RESPONSE_RETRY);
140 reply->writeInt32(ret);
113 } else { 141 } else {
114 reply->writeInt32(-1); 142 reply->writeInt32(GATEKEEPER_RESPONSE_ERROR);
115 } 143 }
116 return NO_ERROR; 144 return NO_ERROR;
117 } 145 }