summaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 7c8beae..0e02726 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -555,4 +555,31 @@ int string_is_ecb_encrypted(char *string, int length_string, int blocksize)
return (count_equal_blocks(string, length_string, blocksize) > (length_string/blocksize));
}
+/**
+* split ciphertext in blocks of size blocksize
+ * @return returns an array of string of size with blocksize elements
+ */
+
+
+char **transpose_blocks(char *ciphertext, int blocksize, int length)
+{
+ char **blocks;
+ int i, j;
+ int number_blocks = length / blocksize;
+
+ blocks = malloc(blocksize*(sizeof(char*)));
+
+ for(i=0;i<blocksize;i++) {
+ blocks[i] = malloc(number_blocks+1);
+ }
+
+ for(j=0;j<blocksize;j++) {
+ for(i=0;i<number_blocks;i++) {
+ blocks[j][i] = ciphertext[(i*blocksize)+j];
+ }
+ }
+
+ return blocks;
+}
+