- Added support for PKCS#1 v2.1 encoding and thus support for the RSAES-OAEP and RSASSA-PSS operations (enabled by POLARSSL_PKCS1_V21)
diff --git a/tests/suites/helpers.function b/tests/suites/helpers.function
index 6717292..6c983a7 100644
--- a/tests/suites/helpers.function
+++ b/tests/suites/helpers.function
@@ -55,3 +55,68 @@
len--;
}
}
+
+/**
+ * This function just returns data from rand().
+ *
+ * rng_state shall be NULL.
+ */
+static int rnd_std_rand( void *rng_state )
+{
+ if( rng_state != NULL )
+ rng_state = NULL;
+
+ return( rand() );
+}
+
+/**
+ * This function only returns zeros
+ *
+ * rng_state shall be NULL.
+ */
+static int rnd_zero_rand( void *rng_state )
+{
+ if( rng_state != NULL )
+ rng_state = NULL;
+
+ return( 0 );
+}
+
+typedef struct
+{
+ unsigned char *buf;
+ int length;
+ int per_call;
+} rnd_info;
+
+/**
+ * This function returns random based on a buffer it receives.
+ *
+ * rng_state shall be a pointer to a rnd_buf structure.
+ *
+ * After the buffer is empty it will return rand();
+ */
+static int rnd_buffer_rand( void *rng_state )
+{
+ rnd_info *info = (rnd_info *) rng_state;
+ int res;
+
+ if( rng_state == NULL )
+ return( rand() );
+
+ res = rand();
+
+ if( info->length >= info->per_call )
+ {
+ memcpy( &res, info->buf, info->per_call );
+ info->buf += info->per_call;
+ info->length -= info->per_call;
+ }
+ else if( info->length > 0 )
+ {
+ memcpy( &res, info->buf, info->length );
+ info->length = 0;
+ }
+
+ return( res );
+}