Add an example .dir-locals.el
[openssl.git] / crypto / ecdsa / ecs_locl.h
index 61b63668caef7e6fc0cba0789544db84cb802fb1..9a0666e20974d2d35da8a3f60d77d9b017cf1464 100644 (file)
@@ -1,13 +1,16 @@
 /* crypto/ecdsa/ecs_locl.h */
+/*
+ * Written by Nils Larsch for the OpenSSL project
+ */
 /* ====================================================================
- * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 2000-2005 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
+ *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *
  */
 
-#include "ecdsa.h"
-
 #ifndef HEADER_ECS_LOCL_H
-#define HEADER_ECS_LOCL_H
+# define HEADER_ECS_LOCL_H
+
+# include <openssl/ecdsa.h>
 
-#ifdef __cplusplus
+#ifdef  __cplusplus
 extern "C" {
 #endif
 
-#define OPENSSL_ECDSA_ABORT(r) { reason = (r); goto err; }
-
-/* some structures needed for the asn1 encoding */
-typedef struct x9_62_fieldid_st {
-        ASN1_OBJECT *fieldType;
-        ASN1_TYPE   *parameters;
-        } X9_62_FIELDID;
+struct ecdsa_method {
+    const char *name;
+    ECDSA_SIG *(*ecdsa_do_sign) (const unsigned char *dgst, int dgst_len,
+                                 const BIGNUM *inv, const BIGNUM *rp,
+                                 EC_KEY *eckey);
+    int (*ecdsa_sign_setup) (EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv,
+                             BIGNUM **r);
+    int (*ecdsa_do_verify) (const unsigned char *dgst, int dgst_len,
+                            const ECDSA_SIG *sig, EC_KEY *eckey);
+    int flags;
+    void *app_data;
+};
 
-typedef struct x9_62_curve_st {
-        ASN1_OCTET_STRING *a;
-        ASN1_OCTET_STRING *b;
-        ASN1_BIT_STRING   *seed;
-        } X9_62_CURVE;
+/* The ECDSA_METHOD was allocated and can be freed */
 
-typedef struct x9_62_ec_parameters {
-        ASN1_INTEGER      *version;
-        X9_62_FIELDID     *fieldID;
-        X9_62_CURVE       *curve;
-        ASN1_OCTET_STRING *base;
-        ASN1_INTEGER      *order;
-        ASN1_INTEGER      *cofactor;
-        } X9_62_EC_PARAMETERS;
+# define ECDSA_METHOD_FLAG_ALLOCATED 0x2
 
-typedef struct ec_parameters {
-       int     type;
-       union {
-               ASN1_OBJECT         *named_curve;
-               X9_62_EC_PARAMETERS *parameters;
-               ASN1_NULL           *implicitlyCA;
-       } value;
-       } EC_PARAMETERS;
-
-typedef struct ecdsa_priv_key_st {
-        int               version;
-        int               write_params;
-        EC_PARAMETERS    *parameters;
-       ASN1_OBJECT       *named_curve;
-        ASN1_OCTET_STRING *pub_key;
-        BIGNUM            *priv_key;
-        } ECDSAPrivateKey;
+/*
+ * If this flag is set the ECDSA method is FIPS compliant and can be used in
+ * FIPS mode. This is set in the validated module method. If an application
+ * sets this flag in its own methods it is its responsibility to ensure the
+ * result is compliant.
+ */
 
+# define ECDSA_FLAG_FIPS_METHOD  0x1
 
-X9_62_FIELDID *ECDSA_get_X9_62_FIELDID(const ECDSA *ecdsa, X9_62_FIELDID *field);
-X9_62_CURVE   *ECDSA_get_X9_62_CURVE(const ECDSA *ecdsa, X9_62_CURVE *curve);
-X9_62_EC_PARAMETERS *ECDSA_get_X9_62_EC_PARAMETERS(const ECDSA *ecdsa, X9_62_EC_PARAMETERS *params);
-EC_PARAMETERS *ECDSA_get_EC_PARAMETERS(const ECDSA *ecdsa, EC_PARAMETERS *params);
+typedef struct ecdsa_data_st {
+    /* EC_KEY_METH_DATA part */
+    int (*init) (EC_KEY *);
+    /* method (ECDSA) specific part */
+    ENGINE *engine;
+    int flags;
+    const ECDSA_METHOD *meth;
+    CRYPTO_EX_DATA ex_data;
+} ECDSA_DATA;
 
-ECDSA  *ECDSA_x9_62parameters2ecdsa(const X9_62_EC_PARAMETERS *params, ECDSA *ecdsa);
-ECDSA  *ECDSA_ecparameters2ecdsa(const EC_PARAMETERS *params, ECDSA *ecdsa);
+/** ecdsa_check
+ * checks whether ECKEY->meth_data is a pointer to a ECDSA_DATA structure
+ * and if not it removes the old meth_data and creates a ECDSA_DATA structure.
+ * \param  eckey pointer to a EC_KEY object
+ * \return pointer to a ECDSA_DATA structure
+ */
+ECDSA_DATA *ecdsa_check(EC_KEY *eckey);
 
 #ifdef  __cplusplus
 }
 #endif
-#endif
+
+#endif                          /* HEADER_ECS_LOCL_H */