Chromium Code Reviews| Index: device/u2f/u2f_apdu_command.cc |
| diff --git a/device/u2f/u2f_apdu_command.cc b/device/u2f/u2f_apdu_command.cc |
| index cd854825e53d8d64367ea5fe2dd4f22f385f44fa..b1964e26f6e297a58912106447d1d5f677722a45 100644 |
| --- a/device/u2f/u2f_apdu_command.cc |
| +++ b/device/u2f/u2f_apdu_command.cc |
| @@ -119,4 +119,59 @@ U2fApduCommand::U2fApduCommand(uint8_t cla, |
| U2fApduCommand::~U2fApduCommand() {} |
| +// static |
| +scoped_refptr<U2fApduCommand> U2fApduCommand::BuildRegisterCommand( |
| + const std::vector<uint8_t>& appid_digest, |
| + const std::vector<uint8_t>& challenge_digest) { |
| + if (appid_digest.size() != kAppIdDigestLen || |
| + challenge_digest.size() != kChallengeDigestLen) { |
| + return nullptr; |
| + } |
| + |
| + scoped_refptr<U2fApduCommand> command = U2fApduCommand::Create(); |
|
Reilly Grant (use Gerrit)
2017/01/28 00:29:29
No "U2fApduCommand::" required here and below.
Casey Piper
2017/01/30 21:51:40
Done.
|
| + std::vector<uint8_t> data(challenge_digest.begin(), challenge_digest.end()); |
| + data.insert(data.end(), appid_digest.begin(), appid_digest.end()); |
| + command->set_ins(kInsU2fEnroll); |
| + command->set_p1(kP1TupRequiredConsumed); |
| + command->set_data(data); |
| + return command; |
| +} |
| + |
| +// static |
| +scoped_refptr<U2fApduCommand> U2fApduCommand::BuildGetVersionCommand() { |
| + scoped_refptr<U2fApduCommand> command = U2fApduCommand::Create(); |
| + command->set_ins(kInsU2fVersion); |
| + return command; |
| +} |
| + |
| +// static |
| +scoped_refptr<U2fApduCommand> U2fApduCommand::BuildGetLegacyVersionCommand() { |
| + scoped_refptr<U2fApduCommand> command = U2fApduCommand::Create(); |
| + command->set_ins(kInsU2fVersion); |
| + command->set_data(std::vector<uint8_t>(2, 0)); |
|
juanlang (chromium.org)
2017/01/28 00:08:39
Comment why two 0 bytes, please.
Casey Piper
2017/01/30 21:51:40
Done.
|
| + return command; |
| +} |
| + |
| +// static |
| +scoped_refptr<U2fApduCommand> U2fApduCommand::BuildSignCommand( |
| + const std::vector<uint8_t>& appid_digest, |
| + const std::vector<uint8_t>& challenge_digest, |
| + const std::vector<uint8_t>& key_handle) { |
| + if (appid_digest.size() != kAppIdDigestLen || |
| + challenge_digest.size() != kChallengeDigestLen || |
| + key_handle.size() > kMaxKeyHandleLength) { |
| + return nullptr; |
| + } |
| + |
| + scoped_refptr<U2fApduCommand> command = U2fApduCommand::Create(); |
| + std::vector<uint8_t> data(challenge_digest.begin(), challenge_digest.end()); |
| + data.insert(data.end(), appid_digest.begin(), appid_digest.end()); |
| + data.push_back(static_cast<uint8_t>(key_handle.size())); |
| + data.insert(data.end(), key_handle.begin(), key_handle.end()); |
| + command->set_ins(kInsU2fSign); |
| + command->set_p1(kP1TupRequiredConsumed); |
| + command->set_data(data); |
| + return command; |
| +} |
| + |
| } // namespace device |