@@ -0,0 +1,2740 @@
+/*%0A * Copyright (c) 2011 United ID. All rights reserved.%0A * Copyright (c) 2011 Yubico AB. All rights reserved.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A *%0A * @author Stefan Wold %3Cstefan.wold@unitedid.org%3E%0A * @author Fredrik Thulin %3Cfredrik@yubico.com%3E%0A */%0A%0Apackage org.unitedid.yhsm.internal;%0A%0Aimport static org.unitedid.yhsm.internal.Defines.*;%0Aimport static org.unitedid.yhsm.utility.Utils.*;%0A%0Aimport org.unitedid.yhsm.utility.Utils;%0A%0Apublic class HsmUnlockCmd %7B%0A%0A    /** Constructor */%0A    private HsmUnlockCmd() %7B%7D%0A%0A    /**%0A     * Have the YubiHSM unlock the HSM operations (those involving the keystore) with a YubiKey OTP.%0A     *%0A     * @param device the YubiHSM device%0A     * @param publicId the YubiKey public id%0A     * @param otp the YubiKey OTP (in hex)%0A     * @return true if unlock was successful%0A     * @throws YubiHSMErrorException error exceptions%0A     * @throws YubiHSMInputException argument exceptions%0A     * @throws YubiHSMCommandFailedException command failed exception%0A     */%0A    public static boolean unlockOtp(DeviceHandler device, String publicId, String otp) throws YubiHSMErrorException, YubiHSMInputException, YubiHSMCommandFailedException %7B%0A        byte%5B%5D idBA = validateByteArray(%22publicId%22, hexToByteArray(publicId), 0, YSM_AEAD_NONCE_SIZE, YSM_AEAD_NONCE_SIZE);%0A        byte%5B%5D otpBA = validateByteArray(%22otp%22, hexToByteArray(otp), 0, YSM_OTP_SIZE, YSM_OTP_SIZE);%0A        byte%5B%5D payload = Utils.concatAllArrays(idBA, otpBA);%0A        return parseResult(CommandHandler.execute(device, YSM_HSM_UNLOCK, payload, true));%0A    %7D%0A%0A    /**%0A     *  Parse the response from the YubiHSM for a previous command.%0A     *%0A     * @param result the result from the last command%0A     * @return boolean indicating success%0A     * @throws YubiHSMCommandFailedException command failed exception%0A     */%0A    private static boolean parseResult(byte%5B%5D result) throws YubiHSMCommandFailedException %7B%0A        if (result%5B0%5D == YSM_STATUS_OK) %7B%0A            return true;%0A        %7D else if (result%5B0%5D == YSM_OTP_INVALID) %7B%0A            return false;%0A        %7D else %7B%0A            throw new YubiHSMCommandFailedException(%22Command %22 + getCommandString(YSM_HSM_UNLOCK) + %22 failed: %22 + getCommandStatus(result%5B0%5D));%0A        %7D%0A    %7D%0A%7D%0A

Add file forgotten in last commit.