2
0

property.pod 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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, however each name must
  34. be unique.
  35. For example: "" defines an empty property definition (i.e., no restriction);
  36. "my.foo=bar" defines a property named I<my.foo> which has a string value I<bar>
  37. and "iteration.count=3" defines a property named I<iteration.count> which
  38. has a numeric value of I<3>.
  39. The full syntax for property definitions appears below.
  40. =head2 Implementations
  41. Each implementation of an algorithm can define any number of
  42. properties.
  43. For example, the default provider defines the property I<provider=default>
  44. for all of its algorithms.
  45. Likewise, OpenSSL's FIPS provider defines I<provider=fips> and the legacy
  46. provider defines I<provider=legacy> for all of their algorithms.
  47. =head2 Queries
  48. A I<property query clause> is a single conditional test.
  49. For example, "fips=yes", "provider!=default" or "?iteration.count=3".
  50. The first two represent mandatory clauses, such clauses B<must> match
  51. for any algorithm to even be under consideration.
  52. The third clause represents an optional clause.
  53. Matching such clauses is not a requirement, but any additional optional
  54. match counts in favor of the algorithm.
  55. More details about that in the B<Lookups> section.
  56. A I<property query> is a sequence of comma separated property query clauses.
  57. It is an error if a property name appears in more than one query clause.
  58. The full syntax for property queries appears below, but the available syntactic
  59. features are:
  60. =over 4
  61. =item *
  62. B<=> is an infix operator providing an equality test.
  63. =item *
  64. B<!=> is an infix operator providing an inequality test.
  65. =item *
  66. B<?> is a prefix operator that means that the following clause is optional
  67. but preferred.
  68. =item *
  69. B<-> is a prefix operator that means any global query clause involving the
  70. following property name should be ignored.
  71. =item *
  72. B<"..."> is a quoted string.
  73. The quotes are not included in the body of the string.
  74. =item *
  75. B<'...'> is a quoted string.
  76. The quotes are not included in the body of the string.
  77. =back
  78. =head2 Lookups
  79. When an algorithm is looked up, a property query is used to determine
  80. the best matching algorithm.
  81. All mandatory query clauses B<must> be present and the implementation
  82. that additionally has the largest number of matching optional query
  83. clauses will be used.
  84. If there is more than one such optimal candidate, the result will be
  85. chosen from amongst those in an indeterminate way.
  86. Ordering of optional clauses is not significant.
  87. =head2 Shortcut
  88. In order to permit a more concise expression of boolean properties, there
  89. is one short cut: a property name alone (e.g. "my.property") is
  90. exactly equivalent to "my.property=yes" in both definitions and queries.
  91. =head2 Global and Local
  92. Two levels of property query are supported.
  93. A context based property query that applies to all fetch operations and a local
  94. property query.
  95. Where both the context and local queries include a clause with the same name,
  96. the local clause overrides the context clause.
  97. It is possible for a local property query to remove a clause in the context
  98. property query by preceding the property name with a '-'.
  99. For example, a context property query that contains "fips=yes" would normally
  100. result in implementations that have "fips=yes".
  101. However, if the setting of the "fips" property is irrelevant to the
  102. operations being performed, the local property query can include the
  103. clause "-fips".
  104. Note that the local property query could not use "fips=no" because that would
  105. disallow any implementations with "fips=yes" rather than not caring about the
  106. setting.
  107. =head1 SYNTAX
  108. The lexical syntax in EBNF is given by:
  109. Definition ::= PropertyName ( '=' Value )?
  110. ( ',' PropertyName ( '=' Value )? )*
  111. Query ::= PropertyQuery ( ',' PropertyQuery )*
  112. PropertyQuery ::= '-' PropertyName
  113. | '?'? ( PropertyName (( '=' | '!=' ) Value)?)
  114. Value ::= NumberLiteral | StringLiteral
  115. StringLiteral ::= QuotedString | UnquotedString
  116. QuotedString ::= '"' [^"]* '"' | "'" [^']* "'"
  117. UnquotedString ::= [^{space},]+
  118. NumberLiteral ::= '0' ( [0-7]* | 'x' [0-9A-Fa-f]+ ) | '-'? [1-9] [0-9]+
  119. PropertyName ::= [A-Z] [A-Z0-9_]* ( '.' [A-Z] [A-Z0-9_]* )*
  120. =head1 HISTORY
  121. Properties were added in OpenSSL 3.0
  122. =head1 COPYRIGHT
  123. Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
  124. Licensed under the Apache License 2.0 (the "License"). You may not use
  125. this file except in compliance with the License. You can obtain a copy
  126. in the file LICENSE in the source distribution or at
  127. L<https://www.openssl.org/source/license.html>.
  128. =cut