Encryption – What should the Hamming weights be between each AES iteration?

I have a task where I have to print out the Hamming weights between each iteration of the AES diffusion steps, and I've got a maximum weight every iteration, but I can not seem to verify that it's correct or not.

It seems as if the task has been given to show that the weights increase as the diffusion progresses, so am I a little suspicious of the constant weights of 1?

Should they be 1 at each iteration?

Algorithms – Image processing system (encryption / decryption) with Residue Number System

I am preparing for my final project at school and plan to work on the implementation of the Residue Number System in image processing.
I found this work online from Pallab Maji Here:

http://ethesis.nitrkl.ac.in/2831/1/Thesis_Final_App_of_RNS_in_Comm__SP.pdf

and I looked on pages 29 – 41, he explained the algorithm with which I do not know some concepts:

  • I: input image and block size m and n.
  • II: Divide the image into mxn blocks and scan the intermediate blocks in zigzag.
  • III: Z = m × n × 8 bits. Create a module set P, where P = {p1, p2 … pk} and equals Z bits.
  • IV: zigzag the scanned intermediate block into a word and scale it to avoid this
    Overflow.
  • V: Use the set P to convert the word to RNA.
  • VI: Re-group the RNA number to form a word and further subdivide it into mxn
    Blocks.
  • VII: Match the encrypted block to the picture.

I would be very grateful if someone could help me enforce it.

How do I check if the custom ROM supports encryption?

The first solution that comes to my mind is installing a custom ROM and encrypting it /data Partition wall. But it always takes time. I wonder if there is a faster method such as downloading a custom ROM, extracting a system image, extracting files from a system image file, and looking for encryption support in system files *.rc which are in the root file system. Is there another way to check?

java – Encryption algorithm that encrypts and decrypts plain text and files from a specific directory

I have created an encryption and decryption algorithm that encrypts plain text using a particular encryption and decrypts it back to the original. That works perfect.

This was my code for a test and the examiner told me that the class structure is reversed as it is done right. In addition, it is sloppy in some places.

I want to know WHAT (or WHEN) about the structure of the classes is wrong. Does it look sloppy? Can someone help me identify any sites that lack Java coding best practices?

Can someone please read and tell me what's wrong with that and how I can improve the class structure?

I have a MyBuilder Class that creates an instance of MyAlgorithm,
MyAlgorithm has the methods to encrypt and decrypt text and adds another class called EncryptionAndDecryption where the actual logic of the algorithm is located.

Here is the code:

public class MyAlgorithm extends EncryptionAndDecryption {

    public enum Action {
        ENCRYPT,
        DECRYPT
    }

    protected MyAlgorithm(final String cipherCharSet) {
        super(cipherCharSet);
    }

    public String encryptText(final String cipher, final String plainText) {
        return encryptOrDecryptText(cipher, plainText, Action.ENCRYPT);
    }

    public String decryptText(String cipher, String encryptedText) {
        return encryptOrDecryptText(cipher, encryptedText, Action.DECRYPT);
    }

    public boolean encryptDirectory(String cipher, String baseDirectory) {
        Path root = Paths.get(baseDirectory);
        try {
            // Lazily traverse to all files from the given baseDirectory.
            Files.walk(root)
                    .filter(Files::isRegularFile)
                    .forEach(file -> encryptOrDecryptFile(cipher, file, baseDirectory, Action.ENCRYPT));
            return true;
        } catch (IOException e) {
            System.err.println("The provided baseDirectory cannot be found or is not readable: <" + baseDirectory + ">");
            return false;
        }
    }

    public boolean decryptDirectory(String cipher, String baseDirectory) {
        Path source = Paths.get(baseDirectory);
        try {
            Files.walk(source)
                    .filter(Files::isRegularFile)
                    .forEach(file -> encryptOrDecryptFile(cipher, file, baseDirectory, Action.DECRYPT));
            return true;
        } catch (IOException e) {
            System.err.println("The provided baseDirectory cannot be found or is not readable: <" + baseDirectory + ">");
            // e.printStackTrace();
            return false;
        }
    }
}

public class EncryptionAndDecryption {

    private final String CIPHER_CHAR_SET;
    private final String ENCRYPTED_DIR_SUFFIX = ".encrypted";
    private final String DECRYPTED_DIR_SUFFIX = ".decrypted";

    protected EncryptionAndDecryption(final String cipherCharSet) {
        this.CIPHER_CHAR_SET = cipherCharSet;
    }

    protected final String encryptOrDecryptText(final String cipher, final String inputText, final MyAlgorithm.Action action) {

        final int cipherSize = cipher.length();
        final int inputSize = inputText.length();
        StringBuilder targetBuilder = new StringBuilder();

        int cipherIndex = 0;
        for (int i = 0; i < inputSize; i++) {

            final int cipherTextPos = getIndexForChar(inputText.charAt(i));

            if(cipherTextPos < 0) {

                targetBuilder.append(inputText.charAt(i));

            } else {

                cipherIndex = cipherIndex == cipherSize ? 0 : cipherIndex;

                // current cipher character
                final char cipherChar = cipher.charAt(cipherIndex);
                // current rotated cipher set.
                final String ROTATED_CIPHER_SET = rotate(String.valueOf(cipherChar));

                if( action == MyAlgorithm.Action.ENCRYPT ) {
                    targetBuilder.append(ROTATED_CIPHER_SET.charAt(getIndexForChar(inputText.charAt(i))));
                } else {
                    int index = ROTATED_CIPHER_SET.indexOf(inputText.charAt(i));
                    targetBuilder.append(CIPHER_CHAR_SET.charAt(index));
                }

                cipherIndex++;
            }
        }
        return targetBuilder.toString();
    }

    protected final void encryptOrDecryptFile(final String cipher, final Path filePath, final String baseDirectory, final MyAlgorithm.Action action) {

        String sourceFilePath = filePath.toFile().getAbsolutePath();
        String pathAfterBaseDir = sourceFilePath.substring(baseDirectory.length()-1);
        String targetFileName = (action == MyAlgorithm.Action.ENCRYPT) ? baseDirectory + ENCRYPTED_DIR_SUFFIX + pathAfterBaseDir
                : baseDirectory + DECRYPTED_DIR_SUFFIX + pathAfterBaseDir;
        Path targetFile = Paths.get(targetFileName);

        try {
            // create target directory and target file.
            Files.createDirectories(targetFile.getParent());
            Files.createFile(targetFile);
        } catch (FileAlreadyExistsException e) {
        } catch (IOException e) {
            e.printStackTrace();
        }

        BufferedInputStream in = null;
        BufferedOutputStream out = null;
        try {

            in = new BufferedInputStream(new FileInputStream(sourceFilePath));
            out = new BufferedOutputStream(new FileOutputStream((targetFileName)));

            byte() bytes = new byte(4096*4096); // reading 16KB at once
            int dataLength;

            while ((dataLength = in.read(bytes)) != -1) {
                for (int i = 0; i < dataLength ; i++) { // writing character by character, to prevent writing extra bytes.
                    String character = String.valueOf((char)bytes(i));
                    out.write(encryptOrDecryptText(cipher, character, action).getBytes());
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(in != null && out != null) {
                try {
                    in.close();
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    private String rotate(String onCharacter) {

        int beginIndex = CIPHER_CHAR_SET.indexOf(onCharacter);
        int endIndex = CIPHER_CHAR_SET.length();

        if(beginIndex == 0) {
            return CIPHER_CHAR_SET;
        } else {
            return CIPHER_CHAR_SET.substring(beginIndex, endIndex) + CIPHER_CHAR_SET.substring(0, beginIndex);
        }
    }

    private int getIndexForChar(char character) {
        try {
            return CIPHER_CHAR_SET.indexOf(character);
        } catch (StringIndexOutOfBoundsException e) {
            return character;
        }
    }
}


public class MyBuilder {

    private String CIPHER_CHAR_SET;

    private MyBuilder() {}

    public static MyBuilder builder() {
        return new MyBuilder();
    }

    public MyBuilder withCipherSet(String cipherSet) {
        this.CIPHER_CHAR_SET = cipherSet;
        return this;
    }

    public MyAlgorithm build() {
        return new MyAlgorithm(CIPHER_CHAR_SET);
    }
}

public class MyEncryptionApp {

    public static final String CIPHER_CHAR_SET = "abcdefghijklmnopqrstuvwxyz";

    public static void main(String args()) {
        if (args.length != 3) {
            System.out.println("Exact 3 parameters required - (action) (key) (target)");
            System.exit(1);
        }

        String action, key, target;
        action = args(0);
        key = args(1);
        target = args(2);

        MyAlgorithm myAlgorithm = MyBuilder.builder()
                .withCipherSet(CIPHER_CHAR_SET)
                .build();

        if ("encrypt".equalsIgnoreCase(action)) {
            System.out.println(myAlgorithm.encryptText(key, target));

        } else if ("decrypt".equalsIgnoreCase(action)) {
            System.out.println(myAlgorithm.decryptText(key, target));

        } else if ("encryptDir".equalsIgnoreCase(action)) {

            if(myAlgorithm.encryptDirectory(key, target)) {
                System.out.println("Directory encryption Successful");
            }

        } else if ("decryptDir".equalsIgnoreCase(action)) {

            if(myAlgorithm.decryptDirectory(key, target)) {
                System.out.println("Directory decryption Successful");
            }

        } else {
            System.out.println("action (" + action + ") not implemented");
        }

    }
}

Encryption – SFTP – What is Public Key is duplicated on another server

I have an SFTP server. My ServerA wants to send a file to the SFTP server, and I am told that ServerA's public key must be stored on the SFTP server for authentication.

My question is whether ServerA's public key will be installed by an internal attacker on another server, and if it somehow also links ServerA to another hacked SFTPServer – the file might end up on the hacked SFTPserver.

Is not that a security risk?

Encryption – Is there a name for this (unconventional?) Use of RSA for authentication?

I'm writing an article about a late 1980s system that uses the RSA algorithm for authentication purposes. In this case, however, instead of the usual method of encrypting a message with a private key, the entire message is encrypted using the following:

Modulus:          n = 0x35... # length 51 bytes / 406 bits
Public exponent:  e = 3       # to maximize performance
Private exponent: d = ...     # such that d⋅e ≡ 1 (mod φ(n))

The message (typically 250 bytes long) is divided into several blocks of 50 bytes each. Each block is then independently encrypted by first adding a prefix (where : Represents chaining):

plaintext = 0x15 : block
ciphertext = (plaintext ^ d) mod n

When reading the ciphertext, each block is restored by decrypting:

plaintext = (ciphertext ^ 3) mod n
assert plaintext(0) == 0x15
block = plaintext(1..)

In terms of authentication, check if the first byte of the plaintext is 0x15 is not particularly useful – decrypting random ciphertext would pass this exam in about 2% of the cases.

Instead, this system relies on the fact that the message would be invalid even after decryption if the message had not been encrypted with the correct private key.

Is there a name for this (unconventional?) Use of public-key cryptography for authentication? Could it be a form of digital signature?

Is it correct in describing this system to refer to the use of the private exponent as "encrypt" and the public exponent as "decrypt" as above? Could the ciphertext be described as "encrypted", "signed" or neither?

Encryption – Phase 1 and Phase 2 during the VPN setup, what kind of data is required

I've read what Phase 1 and Phase 2 of a VPN are and that they include negotiating VPNs to secure the tunnel. However, if I set up a VPN and are asked to provide Phase 1 and Phase 2 to the person setting up the VPN at the other end, what exactly do they expect then? The reason I'm asking is that I set up a VPN at one end and these two phases are not mentioned in the instructions. I have a pre-shared, but Phase 1 and Phase 2 are not mentioned. Are they additional keys or something else?

Photojournalism – Do DSLRs offer in-camera file encryption?

Canon used to sell a data validation kit that signed pictures for review EOS-1Ds Mark III and EOS-1D Mark III (just). However, the review aspect was very poor and was called into question. The answer from Canon was to stop the product and release a weasel note that admits it does not work without saying it.

This does not necessarily mean that the encryption aspect does not work, because if done correctly, this is a simpler problem than checking (which attempts to sign something while hiding the ability to sign-inherently flawed). I disagree with another answer stating that it is practically impossible, but I can not find any good documentation on how the system was implemented by Canon (in general, good security has an open design) and would do so at Canon definitely do not trust it.

Lexar has sold a CF card that, in combination with the Nikon D200, requires hash-based authentication before the card can be accessed. This was sometimes shown as encryption, but it was not. More information can be found in this blog post by security expert Bruce Schneier and in the comments. In short, no real encryption – and for current cameras anyway not available.

Even if you could encrypt properly in the camera, I'm pretty sure that in any situation where you can do it by taking photos on an encrypted device where you refuse to turn the keys over, bother or otherwise punish them Not. For example, this is the law in the UK. And in the US, when the prosecution knows about the existence of incriminating files, the courts have ruled that it is not a violation of the fifth amendment that requires the transfer of files. In totalitarian situations, you may not even get such a big benefit. (Suppose, for example, you are in China – it is illegal there per se To have encryption software on your computers without declaring them.)

You can use something like a multi-tier encryption system with a chaff and a wrong "safe" partition, but if the government thinks you're up to it, it probably will not really help.

It might be possible to encrypt the CHDK or even Magic Lantern firmware hacks, but I think it's complicated and big enough that I would not count on it. Another approach might be an Android app, but you should be very careful that the data never hits Flash unencrypted, and I'm not sure how the camera API internals work. Unfortunately, such an app is not known to me.

To be sure, you must use a public-key algorithm that encrypts with both the public key and the private key elsewhere – You have no way to check the images on the device. This is a little impractical, but nothing more than the inconvenience of waiting until you come to a lab to see what's on a movie roll.

If you are sure of the security of your desktop or laptop, you can keep the private key there. If you plan to edit or manipulate the photos on this device, this is already the weak link. In some situations, this may not be enough and you can leave the private key in an absolutely secure location. Keeping the key in another country at home can have other benefits, as it is plausibly impossible to say that she can solve the mystery. (It might not be good for you shebut the data would remain safe.) In practice, a medium-sized key provides protection for all meaningful attacks, and a larger key continues until all people living today are dead, NP have the value P, or quantum computers become a reality (which is certainly at least a while away)

However, I am not aware of any camera or app that does any of this.

Therefore, it is best if you keep very few files on the cards and completely destroy the cards after use. (Simply deleting, even with a secure delete application, is not enough, and according to your previous question, it's not enough to bite and swallow the card.) Of course, this does not protect you from other risks directly related to the Exposure of your pictures.

C # is a PHP encryption key

I'm trying to convert an encryption that I have in C # and to both encrypt and decrypt it in PHP. I have the ability to do it in mcrypt, but I search it in openssl.

That's the code I have.

    public string Encrypt3DES(string strString)
{
    DESCryptoServiceProvider DES = new DESCryptoServiceProvider();

    DES.Key = System.Text.Encoding.UTF8.GetBytes("12345678");
    DES.Mode = CipherMode.ECB;
    DES.Padding = PaddingMode.Zeros;
    ICryptoTransform DESEncrypt = DES.CreateEncryptor();
    byte() Buffer =  System.Text.Encoding.UTF8.GetBytes(strString);
    return Convert.ToBase64String(DESEncrypt.TransformFinalBlock(Buffer, 0, Buffer.Length));
}

I have to hand it over to PHP. I have implemented an idea like this:

    $string=$string."***".genRandomString();
    $encrypt_code="12345678";
    $encrypt_code = substr($encrypt_code, 0, 8);
    $key = $encrypt_code."";

     $iv_size = openssl_cipher_iv_length($cipher_alg, MCRYPT_MODE_ECB);
        if (!$iv) {
        $iv = openssl_random_pseudo_bytes($iv_size);
        }

    $encrypted_string = openssl_encrypt($string, 'DES-ECB', $key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, $iv);

    return base64_encode($encrypted_string);
    return $string;
}

But no matter what I'm looking for, there is no encryption. Of course in the decrypted change to openssl_decrypt.