mvondracek/PV204_smartcards_Emerald

View on GitHub

Showing 17 of 307 total issues

Method fromBytes has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static jpakePassivePayload fromBytes(byte[] input) throws EmIllegalArgumentException,IllegalArgumentException, ArrayIndexOutOfBoundsException, NullPointerException, SystemException
    {
        short currStart = 0;
        short senderIDlen = input[currStart];
        currStart += 1;
Severity: Major
Found in applet/src/main/java/jpake/jpakePassivePayload.java - About 3 hrs to fix

    Method toBytes has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public byte[] toBytes(){
            byte[] encodedG1 = G1.getEncoded(false);
            byte[] encodedG2 = G2.getEncoded(false);
            byte[] encA = A.getEncoded(false);
            byte[] publicA1Encoded = ZKPx1.getPublicA().getEncoded(false);
    Severity: Major
    Found in applet/src/main/java/jpake/jpakePassivePayload.java - About 2 hrs to fix

      Method fromBytes has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static jpakeActiveFirstPayload fromBytes(byte[] input) throws EmIllegalArgumentException, IllegalArgumentException, ArrayIndexOutOfBoundsException, NullPointerException, SystemException
          {
              short currStart = 0;
              short senderIDlen = input[currStart];
              currStart += 1;
      Severity: Major
      Found in applet/src/main/java/jpake/jpakeActiveFirstPayload.java - About 2 hrs to fix

        File EmeraldApplicationCli.java has 265 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
        Team Emerald (in alphabetical order):
        @OTristanF https://github.com/OTristanF
        @lsolodkova https://github.com/lsolodkova
        @mvondracek https://github.com/mvondracek
        Severity: Minor
        Found in emApplication/src/main/java/emapplication/EmeraldApplicationCli.java - About 2 hrs to fix

          Method toBytes has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public byte[] toBytes(){
                  byte[] encodedG1 = G1.getEncoded(false);
                  byte[] encodedG2 = G2.getEncoded(false);
                  byte[] publicA1Encoded = ZKPx1.getPublicA().getEncoded(false);
                  byte[] publicV1Encoded = ZKPx1.getPublicV().getEncoded(false);
          Severity: Minor
          Found in applet/src/main/java/jpake/jpakeActiveFirstPayload.java - About 1 hr to fix

            Method run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public void run() {
                    printBanner();
                    // connect to the card
                    try {
                        connect(RunConfig.CARD_TYPE.JCARDSIMLOCAL);

              Method fromBytes has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static jpakeActiveSecondPayload fromBytes(byte[] input) throws EmIllegalArgumentException,IllegalArgumentException, ArrayIndexOutOfBoundsException, NullPointerException, SystemException
                  {
                      short currStart = 0;
                      short senderIDlen = input[currStart];
                      currStart += 1;
              Severity: Minor
              Found in applet/src/main/java/jpake/jpakeActiveSecondPayload.java - About 1 hr to fix

                Method performKeyAgreement has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public void performKeyAgreement() throws CardException, EmeraldProtocolException {
                        if (isSecureChannelEstablished()) {
                            // TODO count incorrect counter and consider blocking the application
                            // key agreement for this session already happened
                            throw new EmeraldProtocolException(new EmIllegalStateException());
                Severity: Minor
                Found in applet/src/main/java/applet/SecureChannelManagerOnComputer.java - About 1 hr to fix

                  Method process has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public void process(APDU apdu) {
                          byte[] apduBuffer = apdu.getBuffer();
                  
                          // ignore SELECT command
                          if (selectingApplet()) {
                  Severity: Minor
                  Found in applet/src/main/java/applet/EmeraldApplet.java - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method toBytes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public byte[] toBytes(){
                          byte[] encA = A.getEncoded(false);
                          byte[] encPublicA = ZKPx2s.getPublicA().getEncoded(false);
                          byte[] encPublicV = ZKPx2s.getPublicV().getEncoded(false);
                          byte[] encResult = getZKPx2s().getResult().toByteArray();
                  Severity: Minor
                  Found in applet/src/main/java/jpake/jpakeActiveSecondPayload.java - About 1 hr to fix

                    Method setPassword has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public void setPassword(byte passwordSlotId, String password)
                            throws CardException, EmProtocolError, EmeraldProtocolException {
                            System.out.println(String.format("PC --> SC: Set password `%s` to slot %d.",
                                password, passwordSlotId));
                    
                    

                      Method requirePinInput has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private byte[] requirePinInput() {
                              byte[] pin = new byte[PIN_LENGTH];
                              Scanner scanner = new Scanner(System.in);
                              while (true) {
                                  System.out.println("PC       : Enter 4 digit PIN.");
                      Severity: Minor
                      Found in emApplication/src/main/java/emapplication/EmeraldApplicationCli.java - About 45 mins to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Method verify has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public static boolean verify(ECPoint publicA, ECPoint generator, ECPoint publicV,
                                                BigInteger coFactor, BigInteger result, BigInteger challenge) {
                      Severity: Minor
                      Found in applet/src/main/java/applet/ZKPUtils.java - About 45 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                if(G1 == null || G2 == null || A==null || ZKPx1 == null || ZKPx2 == null || ZKPx2s == null){
                                    throw new CryptoException(CryptoException.ILLEGAL_VALUE);
                                }
                        Severity: Major
                        Found in applet/src/main/java/jpake/jpakePassivePayload.java - About 40 mins to fix

                          Method processKeyAgreement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public void processKeyAgreement(APDU apdu) throws EmeraldProtocolException {
                                  if (isSecureChannelEstablished()) {
                                      // count incorrect counter and consider blocking the card
                                      // key agreement for this session already happened
                                      throw new EmeraldProtocolException(new EmIllegalStateException());
                          Severity: Minor
                          Found in applet/src/main/java/applet/SecureChannelManagerOnCard.java - About 35 mins to fix

                          Cognitive Complexity

                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                          A method's cognitive complexity is based on a few simple rules:

                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                          • Code is considered more complex for each "break in the linear flow of the code"
                          • Code is considered more complex when "flow breaking structures are nested"

                          Further reading

                          Method process has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Confirmed

                              public byte[] process(byte[] message) throws EmeraldProtocolException {
                                  byte slotId = message[PASSWORD_SLOT_ID_OFFSET];
                          
                                  if (!(0 <= slotId && slotId < PASSWORD_SLOTS_COUNT)) {
                                      // incorrect password slot
                          Severity: Minor
                          Found in applet/src/main/java/applet/PasswordManagerSubApplet.java - About 25 mins to fix

                          Cognitive Complexity

                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                          A method's cognitive complexity is based on a few simple rules:

                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                          • Code is considered more complex for each "break in the linear flow of the code"
                          • Code is considered more complex when "flow breaking structures are nested"

                          Further reading

                          Method performKeyAgreement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public void performKeyAgreement() throws CardException, EmeraldProtocolException {
                                  if (isSecureChannelEstablished()) {
                                      // TODO count incorrect counter and consider blocking the application
                                      // key agreement for this session already happened
                                      throw new EmeraldProtocolException(new EmIllegalStateException());
                          Severity: Minor
                          Found in applet/src/main/java/applet/SecureChannelManagerOnComputer.java - About 25 mins to fix

                          Cognitive Complexity

                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                          A method's cognitive complexity is based on a few simple rules:

                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                          • Code is considered more complex for each "break in the linear flow of the code"
                          • Code is considered more complex when "flow breaking structures are nested"

                          Further reading

                          Severity
                          Category
                          Status
                          Source
                          Language