Index: uspace/lib/crypto/aes.c
===================================================================
--- uspace/lib/crypto/aes.c	(revision 1dcc0b9aaf9f79f759ef62cc27bccd9e6b7c8d80)
+++ uspace/lib/crypto/aes.c	(revision d7dadcb4162ebe9a54c5014f67b20ba124ddd307)
@@ -29,10 +29,10 @@
 /** @file aes.c
  * 
- * Implementation of AES algorithm.
+ * Implementation of AES-128 symmetric cipher cryptographic algorithm.
  * 
  * Based on FIPS 197.
  */
 
-#include <stdio.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <mem.h>
@@ -60,5 +60,5 @@
 
 /* Precomputed values for AES sub_byte transformation. */
-static const uint8_t sub_byte_array[BLOCK_LEN][BLOCK_LEN] = {
+static const uint8_t sbox[BLOCK_LEN][BLOCK_LEN] = {
 	{
 		0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 
@@ -128,5 +128,5 @@
 
 /* Precomputed values for AES inv_sub_byte transformation. */
-static uint8_t inv_sub_byte_array[BLOCK_LEN][BLOCK_LEN] = {
+static uint8_t inv_sbox[BLOCK_LEN][BLOCK_LEN] = {
 	{
 		0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 
@@ -202,4 +202,12 @@
 };
 
+/**
+ * Perform substitution transformation on given byte.
+ * 
+ * @param byte Input byte.
+ * @param inv Flag indicating whether to use inverse table.
+ * 
+ * @return Substituted value.
+ */
 static uint8_t sub_byte(uint8_t byte, bool inv)
 {
@@ -208,10 +216,16 @@
 	
 	if(!inv) {
-		return sub_byte_array[i][j];
+		return sbox[i][j];
 	} else {
-		return inv_sub_byte_array[i][j];
-	}
-}
-
+		return inv_sbox[i][j];
+	}
+}
+
+/**
+ * Perform substitution transformation on state table.
+ * 
+ * @param state State table to be modified.
+ * @param inv Flag indicating whether to use inverse table.
+ */
 static void sub_bytes(uint8_t state[ELEMS][ELEMS], bool inv)
 {
@@ -226,4 +240,9 @@
 }
 
+/**
+ * Perform shift rows transformation on state table.
+ * 
+ * @param state State table to be modified.
+ */
 static void shift_rows(uint8_t state[ELEMS][ELEMS])
 {
@@ -237,4 +256,9 @@
 }
 
+/**
+ * Perform inverted shift rows transformation on state table.
+ * 
+ * @param state State table to be modified.
+ */
 static void inv_shift_rows(uint8_t state[ELEMS][ELEMS])
 {
@@ -248,4 +272,12 @@
 }
 
+/**
+ * Multiplication in GF(2^8).
+ * 
+ * @param x First factor.
+ * @param y Second factor.
+ * 
+ * @return Multiplication of given factors in GF(2^8).
+ */
 static uint8_t galois_mult(uint8_t x, uint8_t y) {
         uint8_t result = 0;
@@ -265,4 +297,9 @@
 }
 
+/**
+ * Perform mix columns transformation on state table.
+ * 
+ * @param state State table to be modified.
+ */
 static void mix_columns(uint8_t state[ELEMS][ELEMS])
 {
@@ -294,4 +331,9 @@
 }
 
+/**
+ * Perform inverted mix columns transformation on state table.
+ * 
+ * @param state State table to be modified.
+ */
 static void inv_mix_columns(uint8_t state[ELEMS][ELEMS])
 {
@@ -323,4 +365,10 @@
 }
 
+/**
+ * Perform round key transformation on state table.
+ * 
+ * @param state State table to be modified.
+ * @param round_key Round key to be applied on state table.
+ */
 static void add_round_key(uint8_t state[ELEMS][ELEMS], uint32_t *round_key)
 {
@@ -338,4 +386,11 @@
 }
 
+/**
+ * Perform substitution transformation on given word.
+ * 
+ * @param byte Input word.
+ * 
+ * @return Substituted word.
+ */
 static uint32_t sub_word(uint32_t word)
 {
@@ -350,4 +405,11 @@
 }
 
+/**
+ * Perform left rotation by one byte on given word.
+ * 
+ * @param byte Input word.
+ * 
+ * @return Rotated word.
+ */
 static uint32_t rot_word(uint32_t word)
 {
@@ -355,4 +417,10 @@
 }
 
+/**
+ * Key expansion procedure for AES algorithm.
+ * 
+ * @param key Input key.
+ * @param key_exp Result key expansion.
+ */
 static void key_expansion(uint8_t *key, uint32_t *key_exp)
 {
@@ -379,4 +447,14 @@
 }
 
+/**
+ * AES-128 encryption algorithm.
+ * 
+ * @param key Input key.
+ * @param input Input data sequence to be encrypted.
+ * @param output Encrypted data sequence.
+ * 
+ * @return EINVAL when input or key not specified, ENOMEM when pointer for 
+ * output is not allocated, otherwise EOK.  
+ */
 int aes_encrypt(uint8_t *key, uint8_t *input, uint8_t *output)
 {
@@ -404,15 +482,5 @@
 	for(size_t k = 1; k <= ROUNDS; k++) {
 		sub_bytes(state, false);
-		for(size_t i = 0; i < ELEMS; i++) {
-			for(size_t j = 0; j < ELEMS; j++) {
-				printf("STATE SUB %d %d : %x\n", i, j, state[i][j]);
-			}
-		}
 		shift_rows(state);
-		for(size_t i = 0; i < ELEMS; i++) {
-			for(size_t j = 0; j < ELEMS; j++) {
-				printf("STATE SHIFT %d %d : %x\n", i, j, state[i][j]);
-			}
-		}
 		if(k < ROUNDS)
 			mix_columns(state);
@@ -430,4 +498,14 @@
 }
 
+/**
+ * AES-128 decryption algorithm.
+ * 
+ * @param key Input key.
+ * @param input Input data sequence to be decrypted.
+ * @param output Decrypted data sequence.
+ * 
+ * @return EINVAL when input or key not specified, ENOMEM when pointer for 
+ * output is not allocated, otherwise EOK.  
+ */
 int aes_decrypt(uint8_t *key, uint8_t *input, uint8_t *output)
 {
