PKCS#5 PBES2 now uses OID database for algorithm detection
diff --git a/library/oid.c b/library/oid.c
index a280070..371d1ba 100644
--- a/library/oid.c
+++ b/library/oid.c
@@ -30,7 +30,6 @@
 #if defined(POLARSSL_OID_C)
 
 #include "polarssl/oid.h"
-#include "polarssl/md.h"
 #include "polarssl/rsa.h"
 
 #include <stdio.h>
@@ -202,6 +201,30 @@
 };
 
 /*
+ * For PKCS#5 PBES2 encryption algorithm
+ */
+typedef struct {
+    oid_descriptor_t    descriptor;
+    cipher_type_t       cipher_alg;
+} oid_cipher_alg_t;
+
+static const oid_cipher_alg_t oid_cipher_alg[] =
+{
+    {
+        { OID_DES_CBC,              "desCBC",       "DES-CBC" },
+        POLARSSL_CIPHER_DES_CBC,
+    },
+    {
+        { OID_DES_EDE3_CBC,         "des-ede3-cbc", "DES-EDE3-CBC" },
+        POLARSSL_CIPHER_DES_EDE3_CBC,
+    },
+    {
+        { NULL, NULL, NULL },
+        0,
+    },
+};
+
+/*
  * For digestAlgorithm
  */
 typedef struct {
@@ -452,6 +475,14 @@
                                 oid );
 }
 
+static const oid_cipher_alg_t *oid_cipher_alg_from_asn1( const asn1_buf *oid )
+{
+    return (const oid_cipher_alg_t *) oid_descriptor_from_asn1(
+                                oid_cipher_alg,
+                                sizeof(oid_cipher_alg_t),
+                                oid );
+}
+
 int oid_get_attr_short_name( const asn1_buf *oid, const char **short_name )
 {
     const oid_x520_attr_t *data = oid_x520_attr_from_asn1( oid );
@@ -554,4 +585,17 @@
     return( POLARSSL_ERR_OID_NOT_FOUND );
 }
 
+int oid_get_cipher_alg( const asn1_buf *oid,
+                        cipher_type_t *cipher_alg )
+{
+    const oid_cipher_alg_t *data = oid_cipher_alg_from_asn1( oid );
+
+    if( data == NULL )
+        return( POLARSSL_ERR_OID_NOT_FOUND );
+
+    *cipher_alg = data->cipher_alg;
+
+    return( 0 );
+}
+
 #endif /* POLARSSL_OID_C */