mvondracek/PV204_smartcards_Emerald

View on GitHub

Showing 282 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

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                        byte[] output = new byte[(short)(1+senderID.length+1+encodedG1.length+1
                                       +encodedG2.length+1+encA.length+1+publicA1Encoded.length+1
                                       +publicV1Encoded.length+1+result1.length+1
                                       +publicA2Encoded.length+1+publicV2Encoded.length+1+result2.length+1
                Severity: Major
                Found in applet/src/main/java/jpake/jpakePassivePayload.java and 1 other location - About 1 hr to fix
                applet/src/main/java/jpake/jpakeActiveFirstPayload.java on lines 62..65

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 88.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                        byte[] output = new byte[(short)(1+senderID.length+1+encodedG1.length+1
                                                         +encodedG2.length+1+publicA1Encoded.length+1
                                                         +publicV1Encoded.length+1+result1.length+1
                                                         +publicA2Encoded.length+1+publicV2Encoded.length+1+result2.length)];
                Severity: Major
                Found in applet/src/main/java/jpake/jpakeActiveFirstPayload.java and 1 other location - About 1 hr to fix
                applet/src/main/java/jpake/jpakePassivePayload.java on lines 70..73

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 88.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                              public byte[] derivePlainCommonKey()
                              {
                                  if(this.status != PASSIVE_STATUS.PS_SECOND_INCOMING_VERIFIED) {
                                      throw new EmIllegalStateException();
                                  }
                          Severity: Minor
                          Found in applet/src/main/java/jpake/jpakePassiveActor.java and 1 other location - About 35 mins to fix
                          applet/src/main/java/jpake/jpakeActiveActor.java on lines 79..86

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 47.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                              public byte[] derivePlainCommonKey() {
                                  if(this.status != ACTIVE_STATUS.AS_SECOND_PAYLOAD_PREPARED) {
                                      throw new EmIllegalStateException();
                                  }
                                  byte[] key = super.derivePlainCommonKey();
                          Severity: Minor
                          Found in applet/src/main/java/jpake/jpakeActiveActor.java and 1 other location - About 35 mins to fix
                          applet/src/main/java/jpake/jpakePassiveActor.java on lines 81..90

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 47.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language