property.pod 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. =pod
  2. =head1 NAME
  3. property - Properties, a selection mechanism for algorithm implementations
  4. =head1 DESCRIPTION
  5. As of OpenSSL 3.0, a new method has been introduced to decide which of
  6. multiple implementations of an algorithm will be used.
  7. The method is centered around the concept of properties.
  8. Each implementation defines a number of properties and when an algorithm
  9. is being selected, filters based on these properties can be used to
  10. choose the most appropriate implementation of the algorithm.
  11. Properties are like variables, they are referenced by name and have a value
  12. assigned.
  13. =head2 Property Names
  14. Property names fall into two categories: those reserved by the OpenSSL
  15. project and user defined names.
  16. A I<reserved> property name consists of a single C-style identifier
  17. (except for leading underscores not being permitted), which begins
  18. with a letter and can be followed by any number of letters, numbers
  19. and underscores.
  20. Property names are case-insensitive, but OpenSSL will only use lowercase
  21. letters.
  22. A I<user defined> property name is similar, but it B<must> consist of
  23. two or more C-style identifiers, separated by periods.
  24. The last identifier in the name can be considered the 'true' property
  25. name, which is prefixed by some sort of 'namespace'.
  26. Providers for example could include their name in the prefix and use
  27. property names like
  28. <provider_name>.<property_name>
  29. <provider_name>.<algorithm_name>.<property_name>
  30. =head2 Properties
  31. A I<property> is a I<name=value> pair.
  32. A I<property definition> is a sequence of comma separated properties.
  33. There can be any number of properties in a definition.
  34. For example: "" defines a null property definition; "my.foo=bar"
  35. defines a property named I<my.foo> which has a string value I<bar> and
  36. "iteration.count=3" defines a property named I<iteration.count> which
  37. has a numeric value of I<3>.
  38. The full syntax for property definitions appears below.
  39. =head2 Implementations
  40. Each implementation of an algorithm can define any number of
  41. properties.
  42. For example, the default provider defines the property I<default=yes>
  43. for all of its algorithms.
  44. Likewise, the FIPS provider defines I<fips=yes> and the legacy provider
  45. defines I<legacy=yes> for all of their algorithms.
  46. =head2 Queries
  47. A I<property query clause> is a single conditional test.
  48. For example, "fips=yes", "default!=yes" or "?iteration.count!=3".
  49. The first two represent mandatory clauses, such clauses B<must> match
  50. for any algorithm to even be under consideration.
  51. The third clause represents an optional clause.
  52. Matching such clauses is not a requirement, but any additional optional
  53. match counts in favor of the algorithm.
  54. More details about that in the B<Lookups> section.
  55. A I<property query> is a sequence of comma separated property query clauses.
  56. The full syntax for property queries appears below, but the available syntactic
  57. features are:
  58. =over 4
  59. =item *
  60. B<=> is an infix operator providing an equality test.
  61. =item *
  62. B<!=> is an infix operator providing an inequality test.
  63. =item *
  64. B<?> is a prefix operator that means that the following clause is optional
  65. but preferred.
  66. =item *
  67. B<-> is a prefix operator that means any global query clause involving the
  68. following property name should be ignored.
  69. =item *
  70. B<"..."> is a quoted string.
  71. The quotes are not included in the body of the string.
  72. =item *
  73. B<'...'> is a quoted string.
  74. The quotes are not included in the body of the string.
  75. =back
  76. =head2 Lookups
  77. When an algorithm is looked up, a property query is used to determine
  78. the best matching algorithm.
  79. All mandatory query clauses B<must> be present and the implementation
  80. that additionally has the largest number of matching optional query
  81. clauses will be used.
  82. If there is more than one such optimal candidate, the result will be
  83. chosen from amongst those in an indeterminate way.
  84. Ordering of optional clauses is not significant.
  85. =head2 Shortcut
  86. In order to permit a more concise expression of boolean properties, there
  87. is one short cut: a property name alone (e.g. "default") is
  88. exactly equivalent to "default=yes" in both definitions and queries.
  89. =head2 Global and Local
  90. Two levels of property query are supported.
  91. A context based property query that applies to all fetch operations and a local
  92. property query.
  93. Where both the context and local queries include a clause with the same name,
  94. the local clause overrides the context clause.
  95. It is possible for a local property query to remove a clause in the context
  96. property query by preceding the property name with a '-'.
  97. For example, a context property query that contains "fips=yes" would normally
  98. result in implementations that have "fips=yes".
  99. However, if the setting of the "fips" property is irrelevant to the
  100. operations being performed, the local property query can include the
  101. clause "-fips".
  102. Note that the local property query could not use "fips=no" because that would
  103. disallow any implementations with "fips=yes" rather than not caring about the
  104. setting.
  105. =head1 SYNTAX
  106. The lexical syntax in EBNF is given by:
  107. Definition ::= PropertyName ( '=' Value )?
  108. ( ',' PropertyName ( '=' Value )? )*
  109. Query ::= PropertyQuery ( ',' PropertyQuery )*
  110. PropertyQuery ::= '-' PropertyName
  111. | '?'? ( PropertyName (( '=' | '!=' ) Value)?)
  112. Value ::= NumberLiteral | StringLiteral
  113. StringLiteral ::= QuotedString | UnquotedString
  114. QuotedString ::= '"' [^"]* '"' | "'" [^']* "'"
  115. UnquotedString ::= [^{space},]+
  116. NumberLiteral ::= '0' ( [0-7]* | 'x' [0-9A-Fa-f]+ ) | '-'? [1-9] [0-9]+
  117. PropertyName ::= [A-Z] [A-Z0-9_]* ( '.' [A-Z] [A-Z0-9_]* )*
  118. =head1 HISTORY
  119. Properties were added in OpenSSL 3.0
  120. =head1 COPYRIGHT
  121. Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
  122. Licensed under the Apache License 2.0 (the "License"). You may not use
  123. this file except in compliance with the License. You can obtain a copy
  124. in the file LICENSE in the source distribution or at
  125. L<https://www.openssl.org/source/license.html>.
  126. =cut