Ejemplo n.º 1
0
        // Multiply ECDSA point.
        private int executeKIRKCmd13(ByteBuffer @out, int outSize, ByteBuffer @in, int inSize)
        {
            // Return an error if the crypto engine hasn't been initialized.
            if (!CryptoEngine.CryptoEngineStatus)
            {
                return(PSP_KIRK_NOT_INIT);
            }

            if ((inSize != 0x3C) || (outSize != 0x28))
            {
                // Accept inSize==0x3C and outSize==0x3C as this is sent by sceMemab_9BF0C95D from a real PSP
                if (outSize != inSize)
                {
                    return(PSP_KIRK_INVALID_SIZE);
                }
            }

            // Start the ECDSA context.
            ECDSA            ecdsa = new ECDSA();
            ECDSAMultiplyCtx ctx   = new ECDSAMultiplyCtx(@in, @out);

            ecdsa.setCurve();

            // Multiply the public key.
            ecdsa.multiplyPublicKey(ctx.public_key.toByteArray(), ctx.multiplier);

            ctx.write();

            return(0);
        }
Ejemplo n.º 2
0
        // Generate ECDSA key pair.
        private int executeKIRKCmd12(ByteBuffer @out, int size)
        {
            // Return an error if the crypto engine hasn't been initialized.
            if (!CryptoEngine.CryptoEngineStatus)
            {
                return(PSP_KIRK_NOT_INIT);
            }

            if (size != 0x3C)
            {
                return(PSP_KIRK_INVALID_SIZE);
            }

            // Start the ECDSA context.
            ECDSA          ecdsa = new ECDSA();
            ECDSAKeygenCtx ctx   = new ECDSAKeygenCtx(@out);

            ecdsa.setCurve();

            // Generate the private/public key pair and write it back.
            ctx.private_key = ecdsa.PrivateKey;
            ctx.public_key  = new ECDSAPoint(ecdsa.PublicKey);

            ctx.write();

            return(0);
        }
Ejemplo n.º 3
0
        // Verify ECDSA signature.
        private int executeKIRKCmd17(ByteBuffer @in, int size)
        {
            // Return an error if the crypto engine hasn't been initialized.
            if (!CryptoEngine.CryptoEngineStatus)
            {
                return(PSP_KIRK_NOT_INIT);
            }

            if (size != 0x64)
            {
                return(PSP_KIRK_INVALID_SIZE);
            }

            // TODO
            ECDSA          ecdsa = new ECDSA();
            ECDSAVerifyCtx ctx   = new ECDSAVerifyCtx(@in);

            ecdsa.setCurve();

            return(0);
        }
Ejemplo n.º 4
0
        // Sign data with ECDSA key pair.
        private int executeKIRKCmd16(ByteBuffer @out, int outSize, ByteBuffer @in, int inSize)
        {
            // Return an error if the crypto engine hasn't been initialized.
            if (!CryptoEngine.CryptoEngineStatus)
            {
                return(PSP_KIRK_NOT_INIT);
            }

            if ((inSize != 0x34) || (outSize != 0x28))
            {
                return(PSP_KIRK_INVALID_SIZE);
            }

            // TODO
            ECDSA        ecdsa = new ECDSA();
            ECDSASignCtx ctx   = new ECDSASignCtx(@in);
            ECDSASig     sig   = new ECDSASig();

            ecdsa.setCurve();

            return(0);
        }