Tuesday, January 3, 2023

Published January 03, 2023 by CRYPTO BULL with 0 comment

Hill cipher program in C GTU ,Remove all 3des ciphers from the cipher list specified in sshd_config Cisco



 The Hill cipher is a method of encrypting messages using a simple substitution cipher. It was invented by Lester S. Hill in 1929, and it was the first polygraphic substitution cipher in which it was possible to operate on more than three symbols at once.


In the Hill cipher, the plaintext message is broken up into blocks of size n, and each block is treated as an n-dimensional vector. The key used in the cipher is an n x n matrix, which is used to transform the plaintext vectors into ciphertext vectors.


For example, suppose we have a plaintext message "HELLO" that we want to encrypt using the Hill cipher with a key matrix K and a block size of n = 2. We would break the plaintext into blocks of size 2 like this:



H E

L L

O

We can then represent each block as a 2-dimensional vector:



[7, 4]

[11, 11]

[14]



To encrypt the message, we would multiply each vector by the key matrix K



[7, 4] * K = [17, 22]

[11, 11] * K = [5, 8]

[14] * K = [22]


The resulting vectors are then concatenated to form the ciphertext: "17225822".


To decrypt the message, we would simply apply the inverse of the key matrix to the ciphertext vectors.



The Hill cipher is not widely used in practice, especially compared to more modern and secure ciphers. However, it is still used as a teaching tool for introducing the concept of matrix operations in cryptography. It is also used as a simple example to demonstrate the basic principles of block ciphers and how they can be used to encrypt and decrypt messages.


While the Hill cipher is relatively simple to understand and implement, it is not secure against certain types of attacks, such as known-plaintext attacks. As a result, it is not recommended for use in real-world applications where security is a concern.


Instead, modern ciphers such as the Advanced Encryption Standard (AES) or the Blowfish cipher are generally recommended for use in real-world applications. These ciphers are much more secure and have been designed to withstand a wide range of attacks.


Here is a sample program that demonstrates how to implement the Hill cipher in C:


#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <math.h>


#define MAX_LEN 100

#define MAX_DIM 10


int modulo(int a, int b)

{

    int r = a % b;

    return r < 0 ? r + b : r;

}


void hill_cipher(char *plaintext, int key[MAX_DIM][MAX_DIM], int dim)

{

    int i, j, k, n;

    int c[MAX_DIM];

    char ch;

    n = strlen(plaintext);

    for (i = 0; i < n; i += dim)

    {

        for (j = 0; j < dim; j++)

            c[j] = 0;

        for (j = 0; j < dim; j++)

            for (k = 0; k < dim; k++)

                c[j] = modulo(c[j] + key[j][k] * (plaintext[i + k] - 'A'), 26);

        for (j = 0; j < dim; j++)

            plaintext[i + j] = (char)(c[j] + 'A');

    }

}


int main()

{

    char plaintext[MAX_LEN];

    int key[MAX_DIM][MAX_DIM], dim;

    int i, j;


    printf("Enter the plaintext: ");

    scanf("%s", plaintext);

    printf("Enter the dimension of the key matrix: ");

    scanf("%d", &dim);

    printf("Enter the key matrix: \n");

    for (i = 0; i < dim; i++)

        for (j = 0; j < dim; j++)

            scanf("%d", &key[i][j]);

    hill_cipher(plaintext, key, dim);

    printf("Ciphertext: %s\n", plaintext);

    return 0;

}



This program prompts the user to enter the plaintext, the dimension of the key matrix, and the elements of the key matrix. It then calls the hill_cipher() function to encrypt the plaintext using the Hill cipher. The encrypted text is then printed out.


The hill_cipher() function takes three arguments: the plaintext, the key matrix, and the dimension of the matrix. It works by dividing the plaintext into blocks of size dim, and then applying the key matrix to each block to produce the corresponding ciphertext block.


The modulo() function is a helper function that returns the remainder of a divided by b, taking into account the fact that C's % operator doesn't always return a positive result.


Remove all 3des ciphers from the cipher list specified in sshd_config Cisco


To remove all 3DES ciphers from the list of ciphers used by the Secure Shell (SSH) server on a Cisco device, you will need to edit the sshd_config file and remove the ciphers from the Ciphers configuration option.


Here is an example of how you might do this:


1). Connect to the Cisco device using a terminal emulator such as PuTTY.

2). Enter privileged mode by typing enable and pressing Enter.

3). Enter configuration mode by typing configure terminal and pressing Enter.

4). Navigate to the sshd_config file by typing edit system:ssh/sshd_config and pressing Enter.


5). Use the no command to remove the 3DES ciphers from the Ciphers option. For example:

 code-no Ciphers aes128-ctr,aes192-ctr,aes256-ctr,3des-ctr



6). Save the changes to the sshd_config file by typing exit and pressing Enter.

7). Restart the SSH server to apply the changes by typing ssh server restart and pressing Enter.


This will remove all 3DES ciphers from the list of ciphers used by the SSH server on the Cisco device. Keep in mind that you should only remove ciphers that you are sure are not needed, as doing so may reduce the security of the SSH server.

Related Reading






    email this

0 comments:

Post a Comment